JOB Statements

Job statements are used for management of Flink jobs.

Flink SQL supports the following JOB statements for now:

  • SHOW JOBS
  • DESCRIBE JOB
  • STOP JOB

Run a JOB statement

SQL CLI

The following examples show how to run JOB statements in SQL CLI.

SQL CLI

  1. Flink SQL> SHOW JOBS;
  2. +----------------------------------+----------+---------+-------------------------+
  3. | job id | job name | status | start time |
  4. +----------------------------------+----------+---------+-------------------------+
  5. | 228d70913eab60dda85c5e7f78b5782c | myjob | RUNNING | 2023-02-11T05:03:51.523 |
  6. +----------------------------------+----------+---------+-------------------------+
  7. Flink SQL> DESCRIBE JOB '228d70913eab60dda85c5e7f78b5782c';
  8. +----------------------------------+----------+---------+-------------------------+
  9. | job id | job name | status | start time |
  10. +----------------------------------+----------+---------+-------------------------+
  11. | 228d70913eab60dda85c5e7f78b5782c | myjob | RUNNING | 2023-02-11T05:03:51.523 |
  12. +----------------------------------+----------+---------+-------------------------+
  13. Flink SQL> SET 'execution.checkpointing.savepoint-dir'='file:/tmp/';
  14. [INFO] Execute statement succeeded.
  15. Flink SQL> STOP JOB '228d70913eab60dda85c5e7f78b5782c' WITH SAVEPOINT;
  16. +-----------------------------------------+
  17. | savepoint path |
  18. +-----------------------------------------+
  19. | file:/tmp/savepoint-3addd4-0b224d9311e6 |
  20. +-----------------------------------------+

SHOW JOBS

  1. SHOW JOBS

Show the jobs in the Flink cluster.

Attention SHOW JOBS statements only work in SQL CLI or SQL Gateway.

DESCRIBE JOB

  1. { DESCRIBE | DESC } JOB '<job_id>'

Show the specified job in the Flink cluster.

Attention DESCRIBE JOB statements only work in SQL CLI or SQL Gateway.

STOP JOB

  1. STOP JOB '<job_id>' [WITH SAVEPOINT] [WITH DRAIN]

Stop the specified job.

WITH SAVEPOINT Perform a savepoint right before stopping the job. The savepoint path could be specified with execution.checkpointing.savepoint-dir either in the cluster configuration or via SET statements (the latter would take precedence).

WITH DRAIN Increase the watermark to the maximum value before the last checkpoint barrier. Use it when you want to terminate the job permanently.

Attention STOP JOB statements only work in SQL CLI or SQL Gateway.