JOB Statements

Job statements are used for management of Flink jobs.

Flink SQL supports the following JOB statements for now:

  • SHOW JOBS
  • 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> SET 'state.savepoints.dir'='file:/tmp/';
  8. [INFO] Execute statement succeed.
  9. Flink SQL> STOP JOB '228d70913eab60dda85c5e7f78b5782c' WITH SAVEPOINT;
  10. +-----------------------------------------+
  11. | savepoint path |
  12. +-----------------------------------------+
  13. | file:/tmp/savepoint-3addd4-0b224d9311e6 |
  14. +-----------------------------------------+

SHOW JOBS

  1. SHOW JOBS

Show the jobs in the Flink cluster.

Attention SHOW JOBS 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 state.savepoints.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.