Updated on 2026-11-06 GMT+08:00

Listing SparkSql Jobs

Function

This API is used to query the Spark SQL job list in a workspace. This API is a synchronous API. It supports filtering by job status, creation time, SQL fragment, etc. After a successful call, the job list data is returned directly. You can view job details via the API for viewing Spark SQL job details.

Calling Method

For details, see Calling APIs.

URI

GET /v2/workspaces/{workspace_id}/spark-sqls

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

workspace_id

Yes

String

Definition: Workspace ID, used for resource isolation. This can be viewed on the workspace page of the console.

Constraints: N/A

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

Default Value: N/A

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

marker

No

String

Definition: Job ID cursor position, used for pagination.

Constraints: For the first query, this parameter can be omitted. For subsequent queries, pass the next_marker value returned in the previous response.

Range: Fixed at 36 characters. Only hexadecimal characters, hyphens (-), and underscores (_) are allowed.

Default Value: N/A

limit

No

Integer

Definition: Number of records to query, used to specify the number of jobs returned.

Constraints: N/A

Range: 1 to 100.

Default Value: 10.

page_reverse

No

Boolean

Definition: Whether to query in reverse page order, which specifies the pagination direction.

Constraints: When set to true, the marker parameter must be specified.

Range

  • true: Queries the previous page of data.

  • false: Queries the next page of data.

Default Value: false

endpoint_name

No

String

Definition: Endpoint name, used to specify the SparkSql execution environment for the query.

Constraints: N/A

Range: 1 to 63 characters. Only lowercase letters, digits, and hyphens (-) are allowed. It must start with a lowercase letter and end with a lowercase letter or digit.

Default Value: N/A

statement

No

String

Definition: SQL fragment, used for fuzzy search of jobs containing the specified SQL fragment.

Constraints: N/A

Range: 1 to 128 characters.

Default Value: N/A

create_time_after

No

Long

Definition: Used to query jobs created after this timestamp.

Constraints: N/A

Range: Minimum value: 1764061598000. Unix timestamp in milliseconds.

Default Value: N/A

create_time_before

No

Long

Definition: Used to query jobs created before this timestamp.

Constraints: N/A

Range: Minimum value: 1764061598000. Unix timestamp in milliseconds.

Default Value: N/A

states

No

Array of strings

Definition: List of SparkSql job statuses, used to filter jobs by status. The array elements are of the String type. The meanings of the values are as follows:

  • QUEUED: Queued.

  • RUNNING: Running.

  • CANCELING: Canceling.

  • CANCELED: Canceled.

  • FAILED: Failed.

  • QUEUED_TIMEOUT: Queued timeout.

  • RUNNING_TIMEOUT: Running timeout.

  • SUCCEED: Succeeded.

Constraints: The number of elements in an array cannot exceed 10.

Default Value: N/A

statement_types

No

Array of strings

Definition: List of job types, used to filter jobs by job type. The array elements are of the String type. The meanings of the values are as follows:

  • DDL: Jobs for creating, modifying, or deleting metadata, including DESC/SHOW statements.

  • DCL: Jobs for permission granting and revocation.

  • DQL: Query statements (SELECT).

  • DML: Jobs for appending, deleting, or updating data in tables.

Constraints: The number of elements in an array cannot exceed 4.

Default Value: N/A

statement_id

No

String

Definition: SparkSql job ID, used to query a specific job. It can be obtained from the statement_id in the response of the API for executing a Spark SQL job or from the API for listing Spark SQL jobs.

Constraints: N/A

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

Default Value: N/A

create_user_id

No

String

Definition: Job creator ID, used to filter jobs by creator. This can be obtained by calling the API for querying user information or viewed on the user management page of the console.

Constraints: N/A

Range: 1 to 256 characters.

Default Value: N/A

create_user_name

No

String

Definition: Job creator name, used to filter jobs by creator.

Constraints: N/A

Range: 1 to 256 characters

Default Value: N/A

labels

No

String

Definition: Job tags, used to filter jobs by tags. Format: key=value, where = must be URL-encoded as %3D.

Constraints: N/A

Range: 1 to 1,024 characters

Default Value: N/A

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition: User token. It is obtained by calling the Obtaining an IAM User Token API.

Constraints: N/A

Range: The value can contain a maximum of 65,534 characters, with no character type restrictions.

Default Value: N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

page_info

SparkMarkerPageInfo object

Definition: Pagination cursor information, used to identify the position and quantity of paginated queries.

statements

Array of ListSparkSqlResItem objects

Definition: Detailed SparkSql job list, containing job ID, status, SQL content, and other information.

Table 5 SparkMarkerPageInfo

Parameter

Type

Description

next_marker

String

Definition: Next page cursor, used to identify the starting position of the next page of data. An empty value indicates no more data.

Range: Fixed at 36 characters. Only hexadecimal characters, hyphens (-), and underscores (_) are allowed. Example: 6c98db52-cac2-4ff1-9a91-b7793e95557d.

previous_marker

String

Definition: Previous page cursor, which is used to identify the start position of the previous page of data. If this parameter is left blank, the current page is the first page.

Range: Fixed at 36 characters. Only hexadecimal characters, hyphens (-), and underscores (_) are allowed.

current_count

Integer

Definition: Number of data items on the current page, used to identify the amount of data returned in the current response.

Range: Integer greater than or equal to 0. Maximum value: 100.

Table 6 ListSparkSqlResItem

Parameter

Type

Description

statement_id

String

Definition: Spark SQL job ID, used to uniquely identify a Spark SQL job execution.

Range: 1 to 64 characters. Only hexadecimal characters, hyphens (-), and underscores (_) are allowed. Example: 80ceaaff-3cfc-4162-a56f-70031ea4fa91.

client_token

String

Definition: SparkSql job transaction ID, used to prevent duplicate submissions.

Range: UUID format, 36 characters. Example: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

endpoint_name

String

Definition: Endpoint name, used to specify the SparkSql execution environment.

Range: 1 to 63 characters. Only lowercase letters, digits, and hyphens (-) are allowed. It must start with a lowercase letter and end with a lowercase letter or digit.

endpoint_id

String

Definition: Endpoint ID, which uniquely identifies the SparkSql execution environment.

Range: UUID format, 36 characters.

catalog_context

SparkSqlCatalogContextResponse object

Definition: Catalog context information, used to specify the data catalog and database used by the job.

statement

String

Definition: User SQL statement, used to perform tasks such as data query and data manipulation.

Range: The value can contain a maximum of 500,000 characters, with no character type restrictions.

parameters

Array of SparkSqlParameter objects

Definition: List of placeholder parameters for user SQL content, used to dynamically replace parameters in the SQL.

state

String

Definition: SparkSql job status, used to identify the execution status of the job.

Range

  • QUEUED: Queued.

  • RUNNING: Running.

  • CANCELING: Canceling.

  • CANCELED: Canceled.

  • FAILED: Failed.

  • QUEUED_TIMEOUT: Queue timeout.

  • RUNNING_TIMEOUT: Running timeout.

  • SUCCEED: Succeeded.

statement_type

String

Definition: SQL job type, used to identify the type of the job.

Range

  • DDL: Jobs for creating, modifying, or deleting metadata, including DESC/SHOW statements.

  • DCL: Jobs for permission granting and revocation.

  • DQL: Query statements (SELECT).

  • DML: Jobs for appending, deleting, or updating data in tables.

error

SparkSqlErrorDto object

Definition: SparkSql job error details, containing error description, error code, and other information.

result

SparkSqlResultResponse object

Definition: SparkSql job result information, including the format and path of the query results.

metric_statistics

SparkSqlMetricStatisticsResponse object

Definition: SparkSql job metric statistics, including the amount of data read, data output, and compute resource usage.

log_url

String

Definition: Log OBS archive path, used to store job execution logs.

Range: OBS path format, for example, obs://bucket/aidatalake/workspace_{workspace_id}/spark/endpoint_{endpoint_id}/jobs/logs/{yyyy_MM_dd}/sql-engine-{engine_id}/spark_{app_name}-driver_spark-sql-{endpoint_id}/spark.log. The path is automatically generated and does not need to be constructed. {workspace_id} indicates the workspace ID, {endpoint_id} indicates the endpoint ID, {yyyy_MM_dd} indicates the date, {engine_id} indicates the SQL engine ID, and {app_name} indicates the Spark application name.

create_time

Long

Definition: Job creation time. The value is a Unix timestamp in milliseconds.

Range: N/A

start_time

Long

Definition: Job start time. The value is a Unix timestamp in milliseconds.

Range: N/A

end_time

Long

Definition: Job end time. The value is a Unix timestamp in milliseconds.

Range: N/A

create_user

SparkCreateUser object

Definition: Information about the user who creates the job.

Table 7 SparkSqlCatalogContextResponse

Parameter

Type

Description

catalog_name

String

Definition: Catalog name, used to specify the data catalog used by the job.

Range: The value can contain a maximum of 128 characters, with no character type restrictions.

database_name

String

Definition: Default database name, used to specify the database used by the job.

Range: The value can contain a maximum of 128 characters, with no character type restrictions.

Table 8 SparkSqlParameter

Parameter

Type

Description

key

String

Definition: Placeholder key, used to identify the parameter position in the SQL statement. Example: :key in a SQL statement.

Range: The value can contain 1 to 128 characters, with no character type restrictions.

value

String

Definition: Placeholder value, used to replace the placeholder in the SQL statement. The value must be a string, and the format is determined by value_type. The input formats of DATE and TIMESTAMP are the same (Unix timestamp in milliseconds), but they are converted to different data types.

Range: 1 to 512 characters.

value_type

String

Definition: Placeholder type, used to identify the data type of the placeholder value.

Range

  • STRING: String type.

  • DECIMAL: Fixed-point number type.

  • INTEGER: Integer type.

  • DATE: Date type.

  • TIMESTAMP: Timestamp type.

Table 9 SparkSqlErrorDto

Parameter

Type

Description

message

String

Definition: SparkSql error description, used to explain the specific cause of the error.

Range: 1 to 1,024 characters. Example: Table does not exist.

sql_state

String

Definition: SparkSql error code, used to identify the type of error.

Range: Standard SQL error code format. Example: 42P01.

error_class

String

Definition: SparkSql error type, used to identify the category of the error.

Range: 1 to 128 characters. Example: SCHEMA_ALREADY_EXISTS.

line

Integer

Definition: Error line number, used to locate the error position in the SQL statement.

Range: Integer greater than 0. Example: 2.

start_position

Integer

Definition: Error start position, used to locate the starting character position of the error in the SQL statement.

Range: Integer greater than 0. Example: 2.

Table 10 SparkSqlResultResponse

Parameter

Type

Description

result_format

String

Definition: Query SQL result format, used to specify the storage format of the results.

Range

  • csv: CSV format.

  • arrow: Apache Arrow format.

result_path

String

Definition: OBS path for query SQL results, used to store the result data of the SQL query.

Range: OBS path format, for example, obs://bucket/aidatalake/workspace_{workspace_id}/spark/endpoint_{endpoint_id}/jobs/sql_result/{engine_id}/{yyyy_MM_dd}/{statement_id}/result. The path is automatically generated and does not need to be constructed. {workspace_id} indicates the workspace ID, {endpoint_id} indicates the endpoint ID, {engine_id} indicates the SQL engine ID, {yyyy_MM_dd} indicates the date, and {statement_id} indicates the job ID.

result_records

Long

Definition: Number of rows in the query result, indicating the number of data rows returned by the SQL query.

Range: Integer greater than or equal to 0.

result_bytes

Long

Definition: Number of bytes in the query result, indicating the size of the data returned by the SQL query.

Range: Integer greater than or equal to 0, in bytes.

execution_profile_path

String

Definition: Storage path for the job execution plan, used to store the execution plan information of the job.

Range: OBS path format, for example, obs://bucket/aidatalake/workspace_{workspace_id}/spark/endpoint_{endpoint_id}/jobs/sql_profile/{engine_id}/{yyyy_MM_dd}/{statement_id}/profile. The path is automatically generated and does not need to be constructed. {workspace_id} indicates the workspace ID, {endpoint_id} indicates the endpoint ID, {engine_id} indicates the SQL engine ID, {yyyy_MM_dd} indicates the date, and {statement_id} indicates the job ID.

Table 11 SparkSqlMetricStatisticsResponse

Parameter

Type

Description

bad_records

Long

Definition: Number of dirty data rows, used to identify the number of erroneous data rows found during processing.

Range: Integer greater than or equal to 0.

input_bytes

Long

Definition: Number of data bytes read, used to identify the amount of data read by the job.

Range: Integer greater than or equal to 0, in bytes.

input_records

Long

Definition: Number of data rows read, used to identify the number of data records read by the job.

Range: Integer greater than or equal to 0.

output_bytes

Long

Definition: Number of data bytes output, used to identify the amount of data output by the job.

Range: Integer greater than or equal to 0, in bytes.

output_records

Long

Definition: Number of data rows output, used to identify the number of data records output by the job.

Range: Integer greater than or equal to 0.

cpu_time

Long

Definition: CPU seconds used for computation, used to identify the compute resources consumed by the job.

Range: Integer greater than or equal to 0, in seconds.

Table 12 SparkCreateUser

Parameter

Type

Description

user_id

String

Definition: User ID of the job creator, used to identify the job creator.

Range: The value can contain 1 to 256 characters, with no character type restrictions.

user_name

String

Definition: User name of the job creator, used to identify the job creator.

Range: The value can contain 1 to 256 characters, with no character type restrictions.

Status code: 400

Table 13 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code, used to identify a specific error type.

Range: 0 to 64 characters.

error_msg

String

Definition: Error description, used to explain the cause of an error.

Range: 0 to 512 characters.

solution_msg

String

Definition: Solution description.

Range: 0 to 4,096 characters.

Status code: 401

Table 14 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code, used to identify a specific error type.

Range: 0 to 64 characters.

error_msg

String

Definition: Error description, used to explain the cause of an error.

Range: 0 to 512 characters.

solution_msg

String

Definition: Solution description.

Range: 0 to 4,096 characters.

Status code: 403

Table 15 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code, used to identify a specific error type.

Range: 0 to 64 characters.

error_msg

String

Definition: Error description, used to explain the cause of an error.

Range: 0 to 512 characters.

solution_msg

String

Definition: Solution description.

Range: 0 to 4,096 characters.

Status code: 500

Table 16 Response body parameters

Parameter

Type

Description

error_code

String

Definition: Error code, used to identify a specific error type.

Range: 0 to 64 characters.

error_msg

String

Definition: Error description, used to explain the cause of an error.

Range: 0 to 512 characters.

solution_msg

String

Definition: Solution description.

Range: 0 to 4,096 characters.

Example Requests

Query all SparkSql jobs in the workspace that are in the running or succeeded state, with 2 records per page. Status filter: RUNNING or SUCCEED.

GET /v2/workspaces/{workspace_id}/spark-sqls?limit=2&states=RUNNING&states=SUCCEED

Example Responses

Status code: 200

{
  "page_info" : {
    "next_marker" : "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "current_count" : 2
  },
  "statements" : [ {
    "statement_id" : "6c98db52-cac2-4ff1-9a91-b7793e95557d",
    "client_token" : "019f2601-c9b5-7d94-80f1-b9d3185433fe",
    "endpoint_name" : "spark-endpoint-01",
    "statement_type" : "DQL",
    "state" : "RUNNING",
    "catalog_context" : {
      "catalog_name" : "hive_catalog",
      "database_name" : "default"
    },
    "statement" : "SELECT * FROM table_name LIMIT 100",
    "log_url" : "obs://my-bucket/aidatalake/workspace_a1b2c3d4e5f6470a9c1b8d2e3f4a5b6c/spark/endpoint_9f8e7d6c5b4a39281706f5e4d3c2b1a0/jobs/logs/2026_06_01/sql-engine-6c98db52/spark_ai-datalake-spark-sql-engine-6c98db52-driver_spark-sql-9f8e7d6c/spark.log",
    "create_time" : 1764061598000,
    "start_time" : 1764061698000,
    "create_user" : {
      "user_id" : "user123",
      "user_name" : "admin"
    }
  }, {
    "statement_id" : "01928d08-b98a-73ce-91df-a7a0dc984207",
    "client_token" : "01928d08-b96b-71fb-95ce-cce0789db8de",
    "endpoint_name" : "spark-sql-01",
    "statement_type" : "DQL",
    "state" : "RUNNING",
    "catalog_context" : {
      "catalog_name" : "hive_catalog",
      "database_name" : "db01"
    },
    "statement" : "select * from inventory limit 10",
    "log_url" : "obs://my-bucket/aidatalake/workspace_a1b2c3d4e5f6470a9c1b8d2e3f4a5b6c/spark/endpoint_9f8e7d6c5b4a39281706f5e4d3c2b1a0/jobs/logs/2026_06_01/sql-engine-01928d08/spark_ai-datalake-spark-sql-engine-01928d08-driver_spark-sql-9f8e7d6c/spark.log",
    "create_time" : 1782898538890,
    "start_time" : 1782898615461,
    "create_user" : {
      "user_id" : "user456",
      "user_name" : "admin"
    }
  } ]
}

Status code: 400

{
  "error_code" : "AIDataLake.01011001",
  "error_msg" : "Invalid parameter statement",
  "solution_msg" : "Please check the input parameters according to the documentation(statement for spark sql)."
}

Status code: 401

{
  "error_code" : "AIDataLake.01011003",
  "error_msg" : "auth token not exists in header",
  "solution_msg" : "Please check if auth token is included in the request header."
}

Status code: 403

{
  "error_code" : "AIDataLake.01011005",
  "error_msg" : "current account has no permission",
  "solution_msg" : "Please connect administrators to add permission."
}

Status code: 500

{
  "error_code" : "AIDataLake.01010001",
  "error_msg" : "Internal system error",
  "solution_msg" : "Contact operations for analysis."
}

Status Codes

Status Code

Description

200

SparkSql jobs successfully listed.

400

Invalid request parameter.

401

Authentication failed.

403

Insufficient permissions.

500

Internal server error.