The SHOW JOBS
statement lists all of the types of long-running tasks your cluster has performed, including:
These details can help you understand the status of crucial tasks that can impact the performance of your cluster, as well as help you control them.
SHOW JOBS
statement shows only long-running tasks. For an exhaustive list of jobs running in the cluster, use the SQL Audit Logging (Experimental) feature.Required privileges
By default, only the root
user can execute SHOW JOBS
.
Synopsis
Response
The result list of jobs shows first ongoing jobs, then completed jobs. The list of ongoing jobs is sorted by starting time, whereas the list of completed jobs is sorted by finished time.
The following fields are returned for each job:
Field | Description |
---|---|
job_id |
A unique ID to identify each job. This value is used if you want to control jobs (i.e., pause, resume, or cancel it). |
job_type |
The type of job. Possible values: SCHEMA CHANGE , BACKUP , RESTORE , or IMPORT .Note: Although there is a background job for DROP or TRUNCATE , it does not appear in the output of SHOW JOBS . |
description |
The command that started the job. |
user_name |
The user who started the job. |
status |
The job's current state. Possible values: pending , running , paused , failed , succeeded , or canceled . |
created |
The TIMESTAMP when the job was created. |
started |
The TIMESTAMP when the job began running first. |
finished |
The TIMESTAMP when the job was succeeded , failed , or canceled . |
modified |
The TIMESTAMP when the job had anything modified. |
fraction_completed |
The fraction (between 0.00 and 1.00 ) of the job that's been completed. |
error |
If the job failed , the error generated by the failure. |
coordinator_id |
The ID of the node running the job. |
Examples
Show jobs
> SHOW JOBS;
+----------------+------------+-------------------------------------------+...
| job_id | job_type | description |...
+----------------+------------+-------------------------------------------+...
| 27536791415282 | RESTORE | RESTORE db.* FROM 'azure://backup/db/tbl' |...
+----------------+------------+-------------------------------------------+...
Filter jobs
You can filter jobs by using SHOW JOBS
as the data source for a SELECT
statement, and then filtering the values with the WHERE
clause.
> SELECT * FROM [SHOW JOBS] WHERE job_type = 'RESTORE' AND status IN ('running', 'failed') ORDER BY created DESC;
+----------------+------------+-------------------------------------------+...
| job_id | job_type | description |...
+----------------+------------+-------------------------------------------+...
| 27536791415282 | RESTORE | RESTORE db.* FROM 'azure://backup/db/tbl' |...
+----------------+------------+-------------------------------------------+...