quantile_at_value returning incorrect value for tdigest, however qdigest returning correct value
50% of value is 1. Tdigest returns quantile 0.75 for 1, and qdigest returns correct 0.5 value
WITH test AS (
SELECT
*
FROM (
VALUES
(0.1),(0.2),(0.2),(0.3),(0.4),(0.5),(0.5),(0.5),(0.6),(0.6),
(1.0),(1.0),(1.0),(1.0),(1.0),(1.0),(1.0),(1.0),(1.0),(1.0)
) AS t(val)
)
SELECT
QUANTILE_AT_VALUE(
CAST(CAST(TDIGEST_AGG(val) AS VARBINARY) AS TDIGEST(DOUBLE)),
1.0
) AS p100,
QUANTILE_AT_VALUE(
CAST(CAST(TDIGEST_AGG(val) AS VARBINARY) AS TDIGEST(DOUBLE)),
0.9999
) AS p9999,
QUANTILE_AT_VALUE(
CAST(CAST(qdigest_agg(val) AS VARBINARY) AS QDIGEST(DOUBLE)),
1.0
) AS q_digest
FROM test
quantile_at_value returning incorrect value for tdigest, however qdigest returning correct value
50% of value is 1. Tdigest returns quantile 0.75 for 1, and qdigest returns correct 0.5 value