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.
POST https://moi.matrixorigin.cn/newmoi/query/result
Preparation before calling¶
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 body¶
statement_idstringRequired- The result ID of a successful query execution.
offsetinteger- The row position to start reading, starting from 0.
limitinteger- The maximum number of rows returned this time; when 0 is not provided or is less than or equal to 0, the server uses 1000.
Request example
curl -X POST "https://moi.matrixorigin.cn/newmoi/query/result" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d "{\"statement_id\":\"$STATEMENT_ID\",\"offset\":0,\"limit\":20}"
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.
codeinteger- 200 on success.
data.query_idstring- The ID of the query that produced the result.
data.db_namestring- The database specified during execution.
data.statement_idstring- Statement ID of this result.
data.statusstring- success when the result is successfully read.
data.offsetinteger- The row position where reading starts this time.
data.limitinteger- The maximum number of rows returned for this request.
data.totalinteger- The number of rows actually returned this time.
data.columns[].namestring- Column name.
data.columns[].typestring- The column type returned by the database.
data.result[][].Stringstring- The string value of the cell.
data.result[][].Validboolean- Whether it is a non-NULL value.
Successful response example
{
"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}]
]
}
}
Error response¶
codestring- Error code.
msgstring- Readable error message.
datanull- `null` in an error response.
Error response example
{"code": 404, "message": "SQL 查询结果不存在"}
Follow-up operations¶
Continue to adjust offset and limit to read subsequent lines, or download execution results.