Presto is one of the Open Source query engines included in watsonx.data to provide fast, reliable, and efficient processing of data. Presto's System Connector, implemented in the Open Source Presto, provides information and metrics for queries running on Presto clusters. kill_query (system.runtime.kill_query) is also included as a procedure.
Here, I want to show 2 examples of executing kill_query using presto-cli and Presto Console on watsonx.data 2.1.2.
To Japanese Readers : This is the translated article of Presto: Query を kill する in Qiita.
Syntax
kill_query procedure takes 2 arguments.
query_id is the first required argument that specifies the unique identifier of the query to be killed.
message is the second argument which is optional that allows you to provide a custom message explaining why the query is being killed.
runtime.kill_query(query_id, message)
Example1: presto-cli
In this example, I use 2 presto-cli terminals: Terminal1 and Terminal2
1. Run a long-running query on Terminal1.
presto:hsf100_no_part> select xxxxxxxxxx;
Query 20250428_084814_00195_3pgtu [RUNNING] i[15M 32.9M 11.4M] o[15M 32.9M 11.4M] splits[444/26/25]
2. Identify the query_id of the query which you want to kill
If you are using presto-cli, you see the query_id in the output of Terminal1. Looking at the upper output, you will find query_id is '20250428_084814_00195_3pgtu' in the message "Query 20250428_084814_00195_3pgtu".
3. On Terminal2, run "kill_query" using Query id '20250428_084814_00195_3pgtu' and message 'kill by cpadmin'.
presto> CALL system.runtime.kill_query('20250428_084814_00195_3pgtu','kill by cpadmin');
CALL
presto>
4. The long-running query in Terminal1 is killed as follows.
Query 20250428_084814_00195_3pgtu, FAILED, 3 nodes
Splits: 516 total, 326 done (63.18%)
[Latency: client-side: 0:10, server-side: 0:09] [165M rows, 1.13GB] [18.2M rows/s, 127MB/s]
Query 20250428_084814_00195_3pgtu failed: Query killed. Message: kill by cpadmin
presto:hsf100_no_part>
You can see the error message "kill by cpadmin".
Example 2 Presto Console
1. Open the Presto Console, then "CLUSTER OVERVIEW" is displayed.
Tip: The URL to the Presto Console is available on the engine details screen in Infrastructure Manager of watsonx.data Console. Click on the Presto engine and the hostname (or external host) in the details will show the URL to the Presto Console.
2. Identify the Query you want to kill in "CLUSTER OVERVIEW" and click on the query_id.

3. The "QUERY DETAILS" screen opens. You will find "Kill" button in it.

4. When you press the Kill button, the query ends with "USER ERROR".

"Error Information" at the below shows the following information:
The error message contains "Killed via web UI".
Error Information
Error Type USER_ERROR
Error Code ADMINISTRATIVELY_KILLED (38)
Stack Trace
com.facebook.presto.spi.PrestoException: Query killed. Message: Killed via web UI
at com.facebook.presto.connector.system.KillQueryProcedure.createKillQueryException(KillQueryProcedure.java:92)
5. When the query was running in presto-cli was killed in Presto Console, the following error was displayed:
presto> select xxxx ;
Query 20250428_091258_00199_3pgtu, FAILED, 4 nodes
Splits: 8 total, 4 done (50.00%)
[Latency: client-side: 0:24, server-side: 0:22] [7 rows, 433KB] [0 rows/s, 19.5KB/s]
Query 20250428_091258_00199_3pgtu failed: Query killed. Message: Killed via web UI
presto>
You find "Message: Killed via web UI" is included.
Environment
- OCP Version : 4.16
- CP4D 5.1.2 (watsonx.data 2.1.2)
- Configured Presto engines
- P01(Presto Java) - Type : Presto (Java) v0.286 / Size : Starter / Coordinator Nodes : 1 Worker Nodes : 0
- PCpp (Presto(C++)) - Type : Presto (C++) v0.286 / Size : Starter / Coordinator Nodes : 1 Worker Nodes : 3
#watsonx.data
#PrestoEngine