【ClickHouse实践】ClickHouse中HTTP错误码处理

当您通过 ClickHouse HTTP 接口提交查询时,任何错误都会在响应标头中的一个名为的特殊字段中返回X-ClickHouse-Exception-Code

curl -i 'http://localhost:8123?query=select+*+from+wtf'
HTTP/1.1 404 Not Found
Date: Fri, 03 Sep 2021 16:22:40 GMT
Connection: Keep-Alive
Content-Type: text/plain; charset=UTF-8
X-ClickHouse-Server-Display-Name: localhost
Transfer-Encoding: chunked
X-ClickHouse-Exception-Code: 60
Keep-Alive: timeout=3
X-ClickHouse-Summary: {
    
    "read_rows":"0","read_bytes":"0","written_rows":"0","written_bytes":"0","total_rows_to_read":"0"}

Code: 60, e.displayText() = DB::Exception: Table default.wtf doesn't exist (version 21.3.1.1)

可以使用此查询查看所有可能的 ClickHouse 错误码:

SELECT concat('\t', name, ' = ', toString(number))
FROM
(
    SELECT
        number,
        errorCodeToName(number) AS name
    FROM system.numbers
    LIMIT 2000
)
WHERE NOT empty(errorCodeToName(number))

猜你喜欢

转载自blog.csdn.net/weixin_39992480/article/details/128008838