Updated on 2024-09-30 GMT+08:00

Obtaining SQL Results

Function

This API is used to obtain results returned after the SQL statements for querying SparkSQL and SparkScript jobs in an MRS cluster are executed.

Constraints

None

Debugging

You can debug this API in API Explorer. Automatic authentication is supported. API Explorer can automatically generate sample SDK code and provide the sample SDK code debugging.

URI

  • Format

    GET /v2/{project_id}/clusters/{cluster_id}/job-executions/{job_execution_id}/sql-result

  • Parameter description
    Table 1 URI parameters

    Parameter

    Mandatory

    Type

    Description

    project_id

    Yes

    String

    Explanation

    Project ID. For details about how to obtain the project ID, see Obtaining a Project ID.

    Constraints

    N/A

    Value range

    The value must consist of 1 to 64 characters. Only letters and digits are allowed.

    Default value

    N/A

    cluster_id

    Yes

    String

    Explanation

    Cluster ID. If this parameter is specified, the latest metadata of the cluster that has been patched will be obtained. For details about how to obtain the cluster ID, see Obtaining a Cluster ID.

    Constraints

    N/A

    Value range

    The value can contain 1 to 64 characters, including only letters, digits, underscores (_), and hyphens (-).

    Default value

    N/A

    job_execution_id

    Yes

    String

    Explanation

    Job ID. For details about how to obtain the job ID, see Obtaining a Job ID.

    Constraints

    N/A

    Value range

    N/A

    Default value

    N/A

Request Parameters

None

Response Parameters

Status code: 202

Table 2 Response parameter

Parameter

Type

Description

sql_results

Object

Explanation

The query results of a SQL statement.

Status code: 400

Table 3 Response body parameters

Parameter

Type

Description

error_code

String

Explanation

Error code.

Value range

N/A

error_msg

String

Explanation

Error message.

Value range

N/A

Example Request

Example request for obtaining the SQL result

GET https://{endpoint}/v2/{project_id}/clusters/{cluster_id}/job-executions/{job_execution_id}/sql-result

Example Response

Status code: 202

The SQL statement execution result is obtained.

{
  "sql_results" : {
    "0" : [ {
      "result" : "succeed"
    } ],
    "1" : [ {
      "database" : "default",
      "isTemporary" : "false",
      "tableName" : "src_wordcount"
    } ],
    "2" : [ {
      "result" : "succeed"
    } ],
    "3" : [ {
      "result" : "succeed"
    } ],
    "4" : [ {
      "name" : "a",
      "id" : 1
    }, {
      "name" : "b",
      "id" : 2
    } ]
  }
}

Status code: 400

Failed to obtain the SQL statement execution result.

{
  "error_msg" : "Failed to obtain SQL job results.",
  "error_code" : "0172"
}

Status Codes

See Status Codes.

Error Codes

See Error Codes.