关于Clickhouse的quantileTiming函数

huangapple go评论62阅读模式
英文:

About quantileTiming function of Clickhouse

问题

根据ClickHouse文档所述,quantileTiming函数接受返回浮点数类型的表达式。

当我将浮点字段传递给该函数时,出现了错误:

查询:

SELECT quantileTiming(0.5)(number / 2) FROM numbers(10)
从服务器接收到异常:
状态码500 响应代码: 43e.displayText() = DB::Exception: 函数quantileTiming的参数必须是整数,但其类型为Float64 (版本19.5.3.8)
 错误 <nil>`

有人能告诉我问题出在哪里吗?以及quantilequantileTiming之间有什么区别?quantileTiming使用哪种算法?谢谢。

英文:

As described in ClickHouse docs quantileTiming function accepts an expression returning float type number.

I got an error when i passed a float field to the function:

Query:

SELECT quantileTiming(0.5)(number / 2) FROM numbers(10)
Received exception from server:
StatusCode 500 Response Code: 43, e.displayText() = DB::Exception: Argument for function quantileTiming must be integer, but it has type Float64 (version 19.5.3.8)
 Err <nil>`

Can someone tell me what's the problem? And what's the difference between quantile and quantileTiming. What alg does quantileTiming use? Thanks.

答案1

得分: 1

您的表达式 number / 2 不是整数类型,而是浮点型。

此外,正如文档中所述

该函数期望以毫秒为单位的Unix时间戳格式的输入值,但不验证格式。

从您的问题中不太清楚您试图实现什么。您应该传递以毫秒为单位的Unix时间戳,而不是 number / 2

据我所知,quantile 用于计算我们从统计学中所知的标准分位数。而 quantileTiming 则针对页面加载时间的分位数进行了优化。由于用例更为狭窄,因此至少应该更精确。您可以在ClickHouse存储库的Quantile*.h文件中找到实现。

英文:

Your expression number / 2 is not of type Integer but Float.

Also as said in docs:

> The function expects input values in unix timestamp format in
> milliseconds, but it doesn't validate format.

From your question it's not clear what you're trying to achieve. You should pass unix timestamp in milliseconds instead of number / 2.

AFAIK quantile is used to calculate standard quantiles as we know it from statistics. And quantileTiming is optimised for computing quantiles of page loading times. As the use case is more narrow, it should be more precise at least. You can find implementations in ClickHouse repo in Quantile*.h files.

huangapple
  • 本文由 发表于 2020年1月3日 17:56:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59576424.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定