英文:
About quantileTiming function of Clickhouse
问题
根据ClickHouse文档所述,quantileTiming
函数接受返回浮点数类型的表达式。
当我将浮点字段传递给该函数时,出现了错误:
查询:
SELECT quantileTiming(0.5)(number / 2) FROM numbers(10)
从服务器接收到异常:
状态码500 响应代码: 43,e.displayText() = DB::Exception: 函数quantileTiming的参数必须是整数,但其类型为Float64 (版本19.5.3.8)
错误 <nil>`
有人能告诉我问题出在哪里吗?以及quantile
和quantileTiming
之间有什么区别?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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论