JOB Statements

Job 语句用于管理作业的生命周期。

目前 Flink SQL 支持以下 JOB 语句:

  • SHOW JOBS
  • DESCRIBE JOB
  • STOP JOB

执行 JOB 语句

SQL CLI

以下示例展示如何在 SQL CLI 中执行 JOB 语句.

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

展示 Flink 集群上的作业。

Attention SHOW JOBS 语句仅适用于 SQL CLI 或者 SQL Gateway.

DESCRIBE JOB

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

展示 Flink 集群上的指定作业。

Attention DESCRIBE JOB 语句仅适用于 SQL CLI 或者 SQL Gateway.

STOP JOB

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

停止指定作业。

WITH SAVEPOINT 在作业停止之前执行 Savepoin。 Savepoint 的路径可以通过集群配置的 execution.checkpointing.savepoint-dir 指定, 或者通过 SET 语句指定(后者有更高优先级)。

WITH DRAIN 在触发 savepoint 之前将 Watermark 提升至最大。该操作会可能会触发窗口的计算。请您注意该操作可能导致您之后从该创建的 savepoint 恢复的作业结果不正确。

Attention STOP JOB 语句仅适用于 SQL CLI 或者 SQL Gateway.