我可以在 quantilesExact 中使用 0 和 1 值吗

Can I use 0 and 1 values in quantilesExact

来自 quantile 函数 documentation:

We recommend using a level value in the range of [0.01, 0.99]. Don't use a level value equal to 0 or 1 – use the min and max functions for these cases.

这是否也适用于 quantileExactquantilesExact 函数?

在我的实验中,我发现 quantileExact(0) = minquantileExact(1) = max,但不能确定。

事实证明,对 quantileExactquantilesExact 函数使用 0 和 1 值是安全的。

该建议与准确性无关,而是与分位数*的复杂性有关。 quantileExact 比 max min 重得多。 查看时间差,即使在小型数据集上也能快 8 倍。

create table Speed Engine=MergeTree order by X  
as select number X from numbers(1000000000);

SELECT min(X), max(X) FROM Speed;
┌─min(X)─┬────max(X)─┐
│      0 │ 999999999 │
└────────┴───────────┘
1 rows in set. Elapsed: 1.040 sec. Processed 1.00 billion rows, 8.00 GB (961.32 million rows/s., 7.69 GB/s.)

SELECT quantileExact(0)(X), quantileExact(1)(X) FROM Speed;
┌─quantileExact(0)(X)─┬─quantileExact(1)(X)─┐
│                   0 │           999999999 │
└─────────────────────┴─────────────────────┘
1 rows in set. Elapsed: 8.561 sec. Processed 1.00 billion rows, 8.00 GB (116.80 million rows/s., 934.43 MB/s.)