kll_sketch_get_quantile_float function
Applies to: Databricks Runtime 18.0 and later
Estimates the value at a given quantile rank (or multiple ranks) from a float KLL sketch.
Syntax
kll_sketch_get_quantile_float ( sketch, rank )
Arguments
sketch: ABINARYexpression containing a serializedFLOATKLL sketch.rank: ADOUBLEexpression orARRAY<DOUBLE>of quantile ranks between 0.0 and 1.0, where:- 0.0 is the minimum,
- 0.5 is the median, and
- 1.0 is the maximum.
Returns
- If rank is
DOUBLE: returns aFLOATvalue representing the estimated quantile. - If rank is
ARRAY<DOUBLE>: returnsARRAY<FLOAT>with quantile estimates for each rank.
Notes
- Rank must be between 0.0 and 1.0 inclusive.
- Returns
NULLif the sketch is empty. - Common quantiles: 0.25 (Q1), 0.5 (median), 0.75 (Q3), 0.95 (P95), 0.99 (P99).
Examples
SQL
> WITH sketch_data AS (
SELECT kll_sketch_agg_float(score) AS sketch
FROM VALUES (1.5), (2.3), (3.7) AS T(score)
)
SELECT kll_sketch_get_quantile_float(sketch, 0.5) FROM sketch_data
2.3