【问题标题】:How to set query timeout when using Presto CLI?使用 Presto CLI 时如何设置查询超时?
【发布时间】:2019-05-14 16:07:17
【问题描述】:

我正在使用 bash 脚本中的 presto cli 将一些简单的数据提取到 csv 中。我正在尝试使用 --client-request-timeout 参数并将其设置为 5s(它说默认值为 2m)。我的查询需要大约 1 分钟,但是我没有收到超时错误(我正在尝试查看错误内容,以便我可以在 bash 脚本中处理它以通知查询失败)。

我尝试在 1-10 秒之间切换 --client-request-timeout,但无法使查询超时,并且需要一分钟才能返回。

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;"

我希望 presto-cli 给我一个错误,然后我可以在我的 bash 脚本中处理它。

【问题讨论】:

  • --client-request-timeout 指定请求通信超时。如果 Presto 服务不可用,您可以达到该超时。

标签: presto


【解决方案1】:

您可以使用query_max_execution_time session 属性设置查询时间限制。

SET SESSION query_max_execution_time = '30s';

您可以使用SHOW SESSION 查询(或looking at the source code)获取支持的会话属性列表。

使用presto-cli,使用--session arg 传递这个:

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

例子

$ 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

【讨论】:

    猜你喜欢
    • 2020-03-21
    • 2021-10-15
    • 2011-09-15
    • 1970-01-01
    • 2011-05-14
    • 2016-06-20
    • 2019-11-28
    • 2011-07-25
    • 1970-01-01
    相关资源
    最近更新 更多