Updated on 2022-12-14 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.

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

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

    cluster_id

    Yes

    String

    The cluster ID. For details about how to obtain the cluster ID, see Obtaining a Cluster ID.

    job_execution_id

    Yes

    String

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

Request Parameters

Request parameters

None

Response Parameters

Status code: 202

Table 2 Response parameter

Parameter

Type

Description

sql-results

Object

The query results of a SQL statement.

Status code: 500

Table 3 Response body parameters

Parameter

Type

Description

error_code

String

The error code.

error_msg

String

The error message.

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: 500

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.