View execution result

View the data returned by your successful SQL execution.

If there are many results, you can read them in several times: offset indicates how many previous rows to skip, and limit indicates how many rows can be read at most this time. For example, use offset: 0, limit: 20 to read the first 20 lines; then use offset: 20, limit: 20 to read the next 20 lines.

HTTP
POST $CLOUDSIGMA_API_BASE/query/result

Before you call this API

Configure the regional API endpoint and authentication, and select the target workspace.

First query the execution status, confirm that the status is success and obtain the result ID (statement_id). This interface can only read queries successfully executed by the current identity.

Request

Shell
curl -X POST "$CLOUDSIGMA_API_BASE/query/result" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{\"statement_id\":\"$STATEMENT_ID\",\"offset\":0,\"limit\":20}"

Request body

ParameterTypeRequiredDescription
statement_idstringRequiredThe result ID of a successful query execution.
offsetintegerThe row position to start reading, starting from 0.
limitintegerThe maximum number of rows returned this time; when 0 is not provided or is less than or equal to 0, the server uses 1000.

Successful response

total is the number of rows returned this time, not the total number of rows in the complete result set. Each row in result is arranged in the order of columns; Valid is false, which means that the cell is NULL.

The response fields are as follows.

In this document, [] after a type denotes an array. In a field path, [] denotes each item in an array; for example, data.columns[].name is the name field of each item in the data.columns array.

JSON
{
  "code": 200,
  "data": {
    "query_id": "query_01",
    "db_name": "sales",
    "statement_id": "statement_01",
    "status": "success",
    "offset": 0,
    "limit": 20,
    "total": 1,
    "columns": [
      {"name": "n", "type": "INT64"}
    ],
    "result": [
      [{"String": "1", "Valid": true}]
    ]
  }
}
FieldTypeDescription
codeinteger200 on success.
data.query_idstringThe ID of the query that produced the result.
data.db_namestringThe database specified during execution.
data.statement_idstringStatement ID of this result.
data.statusstringsuccess when the result is successfully read.
data.offsetintegerThe row position where reading starts this time.
data.limitintegerThe maximum number of rows returned for this request.
data.totalintegerThe number of rows actually returned this time.
data.columns[].namestringColumn name.
data.columns[].typestringThe column type returned by the database.
data.result[][].StringstringThe string value of the cell.
data.result[][].ValidbooleanWhether it is a non-NULL value.

Error response

JSON
{"code": 404, "message": "SQL 查询结果不存在"}
FieldTypeDescription
codestringError code.
msgstringReadable error message.
datanull`null` in an error response.

Follow-up operations

Continue to adjust offset and limit to read subsequent lines, or download execution results.

Last updated on