Querying SQL Results
Function
This API is used to query the execution result of an SQL statement in the MRS cluster. MRS 1.9.2 or later supports this API.
URI
- Format
GET /v2/{project_id}/clusters/{cluster_id}/sql-execution/{sql_id}
- Parameter description
Table 1 URI parameter description Parameter
Mandatory
Description
project_id
Yes
Project ID. For details on how to obtain the project ID, see Obtaining a Project ID.
cluster_id
Yes
Cluster ID. For details on how to obtain the cluster ID, see Obtaining a Cluster ID.
sql_id
Yes
SQL execution ID, that is, sql_id in the return result in Submitting an SQL Statement.
Request
Request parameters
None.
Response
| Parameter | Type | Description |
|---|---|---|
| sql_id | String | SQL ID |
| message | String | Error message |
| statement | String | Executed SQL statement |
| status | String | SQL execution status
|
| result_location | String | Path for archiving the final results of the SQL query statement. NOTE: Only the select statement dumps the SQL execution results to result_location. |
| content | Array | SQL execution result NOTE: Only non-select statements return results in content. If the SQL statement does not return results, content is empty. |
Example
- Example request
- Example response
- Example of a successful response
{ "sql_id":"20190909_011820_00151_xxxxx ", "statement":"show tables", "status":"FINISHED", "result_location":" obs://my_bucket/uuid_date/xxxx.csv", "content":[ ["t1"],["t2"],["t3"] ] } - Example of a failed response
{ "sql_id":"20190909_011820_00151_xxxxx", "message":"line 1:1: Table 'hive.default.t1' already exists", "statement":"show tables", "status":"FAILED" }
- Example of a successful response
Status Code
For details about status codes, see Status Codes.
Last Article: Submitting an SQL Statement
Next Article: Cancel an SQL Execution Task
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.