Updated on 2024-04-25 GMT+08:00

Submitting a SQL Job (Discarded)

Function

This API is used to submit jobs to a queue using SQL statements.

This API has been discarded and is not recommended.

The job types support DDL, DCL, IMPORT, EXPORT, QUERY, and INSERT. Functions of IMPORT and EXPORT are the same as those described in Importing Data (Discarded) and Exporting Data (Discarded). The difference lies in the implementation method.

Additionally, you can use other APIs to query and manage jobs. For details, see the following sections:

  • This API is synchronous if job_type in the response message is DCL.
  • Information described in this section has been disused. You are advised to view the information described in Submitting a SQL Job (Recommended).

URI

  • URI format

    POST /v1.0/{project_id}/queues/{queue_name}/jobs/submit-job

  • Parameter description
    Table 1 URI parameters

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Project ID, which is used for resource isolation. For details about how to obtain its value, see Obtaining a Project ID.

    queue_name

    Yes

    Current queue name. Resources of the queue are used for computing if SQL requires resources.

Request

Table 2 Request parameters

Parameter

Mandatory

Type

Description

sql

Yes

String

SQL statement that you want to execute.

currentdb

No

String

Database where the SQL statement is executed. This parameter does not need to be configured during database creation.

conf

No

Array of objects

User-defined parameter that applies to the job. Currently, the following configuration items are supported:

  • dli.sql.join.preferSortMergeJoin (specifies whether SortMergeJoin is preferred)
  • dli.sql.autoBroadcastJoinThreshold (specifies the data volume threshold to use BroadcastJoin. If the data volume exceeds the threshold, BroadcastJoin will be automatically enabled.)
  • dli.sql.caseSensitive (specifies whether SQL statements are case-sensitive)
  • dli.sql.shuffle.partitions (specifies the number of partitions during shuffling)
  • dli.sql.cbo.enabled (specifies whether to enable the CBO optimization policy)
  • dli.sql.cbo.joinReorder.enabled (specifies whether join reordering is allowed when CBO optimization is enabled)

Response

Table 3 Response parameters

Parameter

Mandatory

Type

Description

is_success

Yes

Boolean

If job_type is set to DCL, this parameter indicates whether the request is successfully executed. Value true indicates that the request is successfully executed.

message

Yes

String

System prompt. If execution succeeds, the parameter setting may be left blank.

job_id

Yes

String

ID of a job returned after a job is generated and submitted by using SQL statements. The job ID can be used to query the job status and results.

job_type

Yes

String

Type of a job. Job types include the following:

  • DDL
  • DCL
  • IMPORT
  • EXPORT
  • QUERY
  • INSERT

schema

No

Array of Map

If the statement type is DDL, the column name and type of DDL are displayed.

rows

No

Array of objects

When the statement type is DDL, results of the DDL are displayed.

Example

  • Example request
    {
        "currentdb": "db1",
        "sql": "desc table1",
        "conf": [
            "dli.sql.shuffle.partitions = 200"
        ]
    }
  • Example response (successful request)
    {
      "is_success": true,
      "message": "",
      "job_id": "8ecb0777-9c70-4529-9935-29ea0946039c",
      "job_type": "DDL",
      "schema": [
        {
          "col_name": "string"
        },
        {
          "data_type": "string"
        },
        {
          "comment": "string"
        }
      ],
      "rows": [
        [
          "c1",
          "int",
          null
        ],
        [
          "c2",
          "string",
          null
        ]
      ]
    }

    If an error occurs when this API is invoked, the system does not return the result similar to the preceding example, but returns the error code and error information. For details, see Error Codes.