py_guy_5
py_guy_5

Reputation: 43

How to set query timeout when using Presto CLI?

I am using the presto cli from a bash script to extract some simple data to a csv. I am trying to use the --client-request-timeout parameter and set it to 5s (it says the default is 2m). My query takes ~1 minute, however I do not get a timeout error (I am trying to see what the error says so I can handle it in the bash script to notify query failure).

I have tried toggling --client-request-timeout from 1-10 seconds but cannot get the query to timeout, and it is taking up to a minute to return.

sudo /folder/to/presto-cli --server server:8080 --catalog catalog --user user --schema some_customer --client-request-timeout 5s --execute "select val1, val2, sum(count) from table where processed=false group by val1, val2;"

I am expecting the presto-cli to give me an error that I can then handle in my bash script.

Upvotes: 0

Views: 6167

Answers (1)

Piotr Findeisen
Piotr Findeisen

Reputation: 20770

You can set query time limit using query_max_execution_time session property.

SET SESSION query_max_execution_time = '30s';

You can get the list of supported session properties with SHOW SESSION query (or looking at the source code).

With presto-cli, use --session arg to pass this:

presto-cli --session query_max_execution_time=30s ... 

Example

$ presto-cli --session query_max_execution_time=15s \
    --execute "select count(distinct regexp_extract(comment, '([a-zA-Z ]+)+$')) from tpch.tiny.lineitem"

Query failed: Query exceeded the maximum execution time limit of 15.00s

Upvotes: 7

Related Questions