...
Query lifecycle statements mainly interact with deployments (clusters and jobs) and have few connections with Table/SQL concepts, thus it’d be better to keep them SQL-client-only like jar statements.
Note:
- The keyword for Flink SQL jobs is under discussion. The alternatives are QUERIES/JOBS/TASKS at the moment. For simplicity, we use QUERY/QUERIES as the keyword in the FLIP, and we would determine the final keyword after discussion.
- All the <query_id> and <savepoint_path> should be string literals (wrapped in single quotes), otherwise it's hard to parse them.
SHOW RUNNING FLINK SQL JOBS
This statement statement lists the queries in the Flink cluster, which is similar to flink list in CLI.
...
Code Block | ||||
---|---|---|---|---|
| ||||
+----------------------------------+-------------+----------+------------|----------+--------------+----------------------|+ | query_id | query_name | status | start_time | duration | address web_ur | +----------------------------------+-------------+----------|----------------------|--------------|----------------------| | cca7bc1061d61cf15238e92312c2fc20 | query1 | RUNNING | 2022-05-01 10:20:33 | 10h 25m 42s | http://127.0.0.1:8081| | 0f6413c33757fbe0277897dd94485f04 | query2 | FAILED | 2022-05-01 14:04:24 | 5h 5m 23s | http://127.0.0.1:8081| +----------------------------------+-------------+----------+----------------------+--------------+--------|--------------|+ |
STOP A RUNNING FLINK SQL JOB
This statement stops a non-terminated SQL, which is similar to `flink stop` in CLI. As stop command has a `--drain` option, we should introduce a table config like `sql-client.stop-with-drain` to support the same functionality.
There are mainly two styles of syntax:
Code Block | ||||
---|---|---|---|---|
| ||||
STOPDROP QUERY '<query_id>' |
The result would the savepoint path.
Code Block | ||||
---|---|---|---|---|
| ||||
+-----------------------------------------------------------------| | savepoint_path | +-----------------------------------------------------------------| | hdfs://tmpmycluster/flink-savepoints/savepoint-cca7bc-bb1e257f0dab | +-----------------------------------------------------------------| |
CANCEL A RUNNING FLINK SQL JOB
This statement statement cancels a non-terminated query, which is similar to `flink cancel` in CLI. A PURGE keyword is introduced to represent "without savepoint".
Code Block | ||||
---|---|---|---|---|
| ||||
DROPCANCEL QUERY '<query_id>' PURGE |
Since CANCEL QUERY
doesn’t an ungrateful drop doesn’t trigger a savepoint, the result would be a simple OK, like the one returned by DDL.
...
This statement triggers savepoints for the specified query, which is similar to `flink savepoint` in CLI.
There're mainly 2 styles of syntax:
Option 1:
Code Block | ||||
---|---|---|---|---|
| ||||
CREATE SAVEPOINT <query_id> |
Option 2
We could follow the savepoint syntax in SQL standard, which is widely used in a transaction block.
Code Block | ||||
---|---|---|---|---|
| ||||
SAVEPOINT '<query_id>' |
The result would the savepoint path.
...
This statement deletes the specified savepoint, which is similar to `flink savepoint –dispose` in CLI.
There're mainly 2 styles of syntax:
Option 1
Code Block | ||||
---|---|---|---|---|
| ||||
DROP SAVEPOINT <savepoint_path> |
Option 2
Code Block | ||||
---|---|---|---|---|
| ||||
RELEASE SAVEPOINT '<savepoint_path>' |
The result would be a simple OK.
...
SQL operator | SQL operation |
SqlShowQueries | ShowQueriesOperation |
SqlStopQuerySqlDropQuery | StopQueryOperationDropQueryOperation |
SqlCancelQuerySqlDroplQueryPurge | CancelQueryOperationDropQueryPurgeOperation |
SqlCreateSavepointSqlSavepoint | CreateSavepointOperationSavepointOperation |
SqlDropSavepointSqlReleaseSavepoint | DropSavepointOperationReleaseSavepointOperation |
Executor
Executor would need to convert the query lifecycle operations into ClusterClient commands.
SQL operation | Cluster Client Command |
ShowQueriesOperation | ClusterClient#listJobs |
StopQueryOperationDropQueryOperation | ClusterClient#stoplWithSavepoint |
CancelQueryOperationDropQueryPurgeOperation | ClusterClient#cancel |
CreateSavepointOperationSavepointOperation | ClusterClient#triggerSavepoint |
DropSavepointOperationSqlReleaseSavepoint | ClusterClient#disposeSavepoint |
...
The new keywords are:
- QUERY (new)
- QUERIES (new)
- STOP (new)
- CANCEL RELEASE (new)
- SAVEPOINT (already reserved)
...