This API is used to submit jobs to a queue using SQL statements.
The job types support DDL, DCL, IMPORT, QUERY, and INSERT. The IMPORT function is the same as that described in Importing Data (Deprecated). 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.
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
project_id |
Yes |
String |
Definition Project ID, which is used for resource isolation. For how to obtain a project ID, see Obtaining a Project ID. Example: 48cc2c48765f481480c7db940d6409d1 Constraints None Range The value can contain up to 64 characters. Only letters and digits are allowed. Default Value None |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
sql |
Yes |
String |
Definition SQL statement to be executed Constraints None Range None Default Value None |
currentdb |
No |
String |
Definition Database where the SQL statement is executed. This parameter does not need to be configured during database creation. Constraints None Range The value cannot contain only digits or start with an underscore (_). Only digits, letters, and underscores (_) are allowed. Default Value None |
queue_name |
No |
String |
Definition Name of the queue to which the job is to be submitted Constraints None Range The name cannot contain only digits or start with an underscore (_). Only digits, letters, and underscores (_) are allowed. Default Value None |
conf |
No |
Array of strings |
Definition You can set the parameter in key-value pairs. Constraints None Range For details about the supported configuration items, see Table 3. Default Value None |
tags |
No |
Array of objects |
Definition Job tags. For details, see Table 4. Constraints None Range None Default Value None |
engine_type |
No |
String |
Definition Type of the engine that executes jobs. Constraints None Range Only the Spark engine is currently supported. The default value is spark. Default Value spark |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
key |
Yes |
String |
Definition Tag key Constraints None Range A tag key can contain up to 128 characters, cannot start or end with a space, and cannot start with _sys_. Only letters, digits, spaces, and the following special characters are allowed: _.:+-@ Default Value None |
value |
Yes |
String |
Definition Tag value Constraints None Range A tag value can contain up to 255 characters. Only letters, digits, spaces, and the following special characters are allowed: _.:+-@ Default Value None |
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
is_success |
Yes |
Boolean |
Definition Whether the request is successfully executed. true indicates that the request is successfully executed. Range None |
message |
Yes |
String |
Definition System prompt. If the execution succeeds, this parameter may be left blank. Range None |
job_id |
Yes |
String |
Definition ID of a job returned after a job is generated and submitted using SQL statements. The job ID can be used to query the job status and results. Range None |
job_type |
Yes |
String |
Definition Job type Range DDL, DCL, IMPORT, EXPORT, QUERY, and INSERT.
|
schema |
No |
Array of Map |
Definition If the statement type is DDL, the column name and type of DDL are displayed. Range None |
rows |
No |
Array of objects |
Definition When the statement type is DDL and dli.sql.sqlasync.enabled is set to false, the execution results are returned directly. However, only a maximum of 1,000 rows can be returned. If there are more than 1,000 rows, obtain the results asynchronously. That is, when submitting the job, set xxxx to true, and then obtain the results from the job bucket configured by DLI. The path of the results on the job bucket can be obtained from the result_path in the return value of the ShowSqlJobStatus API. The full data of the results will be automatically exported to the job bucket. Range None |
job_mode |
No |
String |
Definition Job execution mode. Options:
Range None |
Submit a SQL job. The job execution database and queue are db1 and default, respectively. Then, add the tags workspace=space1 and jobName=name1 for the job.
{
"currentdb": "db1",
"sql": "desc table1",
"queue_name": "default",
"conf": [
"dli.sql.shuffle.partitions = 200"
],
"tags": [
{
"key": "workspace",
"value": "space1"
},
{
"key": "jobName",
"value": "name1"
}
]
}
{
"is_success": true,
"message": "",
"job_id": "8ecb0777-9c70-4529-9935-29ea0946039c",
"job_type": "DDL",
"job_mode":"sync",
"schema": [
{
"col_name": "string"
},
{
"data_type": "string"
},
{
"comment": "string"
}
],
"rows": [
[
"c1",
"int",
null
],
[
"c2",
"string",
null
]
]
}
Table 6 describes status codes.
If an error occurs when this API is called, the system does not return the result similar to the preceding example, but returns an error code and error message. For details, see Error Codes.