doc-exports/docs/mrs/api-ref/mrs_02_0090.html
Yang, Tong bd2b57f749 MRS API 2.0.38.SP20 version
Reviewed-by: gtema <artem.goncharov@gmail.com>
Co-authored-by: Yang, Tong <yangtong2@huawei.com>
Co-committed-by: Yang, Tong <yangtong2@huawei.com>
2022-11-16 15:06:08 +00:00

7.1 KiB

Obtain the SQL Result

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 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.

    job_execution_id

    Yes

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

Request

Request parameters

None

Response

Table 2 Response parameter description

Parameter

Type

Description

sql-results

Object

SQL statement query result.

Example

  • Example request
    {
    	"job_name": "111",
    	"job_type": "SparkSql",
    	"arguments": [
                 "create table src_wordcount (id int,name string);
                  show tables;
                  insert INTO src_wordcount VALUES (1, 'a');
                  insert INTO src_wordcount VALUES (2, 'b');SELECT * FROM src_wordcount;"
                      ],
    	"properties": {}
    }
  • Example response
    • Example of a successful response
      {
      	"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"
      		}]
      	}
      }
    • Example of a failed response
      {
      "error_msg": "Failed to collect SQL job results."
      "error_code":"0172"
      }

Status Code

For details about status codes, see Status Codes.