Help Center/ DataArts Fabric/ API Reference/ APIs/ SQL APIs/ Obtaining Statement Execution Results and Status
Updated on 2025-09-15 GMT+08:00

Obtaining Statement Execution Results and Status

Function

This API is used to query the execution result of a SQL statement. You can call this API to query the execution result of a SQL statement by entering the endpoint ID, SQL session ID, and statement ID. The API then returns the execution result. This API is synchronous with no accompanying APIs or specific scenarios.

URI

GET /v1/workspaces/{workspace_id}/sessions/{session_id}/statements/{statement_id}

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

workspace_id

Yes

String

Definition: Workspace ID.

Constraints: N/A.

Range: 1 to 36 characters. Only letters, digits, and hyphens (-) are allowed.

Default Value: N/A.

session_id

Yes

String

Definition: Session ID.

Constraints: N/A.

Range: 1 to 36 characters. Only letters, digits, and hyphens (-) are allowed.

Default Value: N/A.

statement_id

Yes

String

Definition: Statement ID.

Constraints: N/A.

Range: 1 to 64 characters. Only letters, digits, hyphens (-), and underscores (_) are allowed.

Default Value: N/A.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

page_num

No

Integer

Definition: Page number.

Constraints: N/A.

Range: [1, 65535].

Default Value: N/A.

is_enable_obs_path

No

Boolean

Definition: Whether to return the OBS path of a result set.

Constraints: N/A.

Range: true: The OBS path of the result set will be returned. false: The result set will be returned.

Default Value: N/A.

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

No

String

Definition: Tenant token.

Constraints: N/A.

Range: N/A.

Default Value: N/A.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

-

String

SQL execution result, in string format. For details, see the Example Response.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code.

Constraints: N/A.

Range: [8, 36].

Default Value: N/A.

error_msg

String

Definition: Error message.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

solution_msg

String

Definition: Solution description.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

Status code: 401

Table 6 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code.

Constraints: N/A.

Range: [8, 36].

Default Value: N/A.

error_msg

String

Definition: Error message.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

solution_msg

String

Definition: Solution description.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

Status code: 404

Table 7 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code.

Constraints: N/A.

Range: [8, 36].

Default Value: N/A.

error_msg

String

Definition: Error message.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

solution_msg

String

Definition: Solution description.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

Status code: 408

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code.

Constraints: N/A.

Range: [8, 36].

Default Value: N/A.

error_msg

String

Definition: Error message.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

solution_msg

String

Definition: Solution description.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code.

Constraints: N/A.

Range: [8, 36].

Default Value: N/A.

error_msg

String

Definition: Error message.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

solution_msg

String

Definition: Solution description.

Constraints: N/A.

Range: [2, 4096].

Default Value: N/A.

Example Requests

Query the execution result of a SQL statement. You can call this API to query the execution result of a SQL statement by entering the endpoint ID, SQL session ID, and statement ID. The API then returns the execution result. This API is synchronous with no accompanying APIs or specific scenarios.

GET https://endpoint/v1/workspaces/{workspace_id}/sessions/{session_id}/statements/{statement_id}

{ }

Example Responses

Status code: 200

OK

{
  "status" : 0,
  "session_id" : "6399466e-8908-4c9d-8399-48479c8b06f7",
  "statement_id" : "49131d25-1824-4f29-860c-832bdd19dfd3",
  "results" : [ {
    "status" : "PGRES_TUPLES_OK",
    "statement_id" : "49131d25-1824-4f29-860c-832bdd19dfd3",
    "num_rows" : 2,
    "row_count" : 2,
    "page_count" : 1,
    "page_no" : 1,
    "err_code" : "0",
    "sql_state" : "0",
    "message" : "",
    "result_set" : {
      "columns" : [ {
        "name" : "a",
        "table_id" : 2147483647,
        "column_id" : 1,
        "format" : 0,
        "type" : 23,
        "size" : 4,
        "type_mod" : -1
      }, {
        "name" : "b",
        "table_id" : 2147483647,
        "column_id" : 2,
        "format" : 0,
        "type" : 23,
        "size" : 4,
        "type_mod" : -1
      } ],
      "rows" : [ [ "1", "2" ], [ "1", "2" ] ]
    }
  } ]
}

Status code: 400

BadRequest

{
  "error_code" : "common.01000001",
  "error_msg" : "failed to read http request, please check your input, code: 400, reason: Type mismatch., cause: TypeMismatchException"
}

Status code: 401

Unauthorized

{
  "error_code" : "APIG.1002",
  "error_msg" : "Incorrect token or token resolution failed"
}

Status code: 403

Forbidden

{
  "error" : {
    "code" : "403",
    "message" : "X-Auth-Token is invalid in the request",
    "title" : "Forbidden"
  },
  "error_code" : 403,
  "error_msg" : "X-Auth-Token is invalid in the request",
  "title" : "Forbidden"
}

Status code: 404

NotFound

{
  "error_code" : "common.01000001",
  "error_msg" : "response status exception, code: 404"
}

Status code: 408

Request Time-out

{
  "error_code" : "common.00000408",
  "error_msg" : "timeout exception occurred"
}

Status code: 500

InternalServerError

{
  "error_code" : "common.00000500",
  "error_msg" : "internal error"
}

Status Codes

Status Code

Description

200

OK

400

BadRequest

401

Unauthorized

403

Forbidden

404

NotFound

408

Request Time-out

500

InternalServerError

Error Codes

See Error Codes.