メインコンテンツまでスキップ

kll_sketch_get_quantile_double function

Applies to: check marked yes Databricks Runtime 18.0 and later

Estimates the value at a given quantile rank (or multiple ranks) from a double KLL sketch.

Syntax

kll_sketch_get_quantile_double ( sketch, rank )

Arguments

  • sketch: A BINARY expression containing a serialized DOUBLE KLL sketch.
  • rank: A DOUBLE expression or ARRAY<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 a DOUBLE value representing the estimated quantile.
  • If rank is ARRAY<DOUBLE>: returns ARRAY<DOUBLE> with quantile estimates for each rank.

Notes

  • Rank must be between 0.0 and 1.0 inclusive.
  • Returns NULL if 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_double(value) AS sketch
FROM VALUES (1.23), (2.34), (3.45) AS T(value)
)
SELECT kll_sketch_get_quantile_double(sketch, array(0.25, 0.75)) FROM sketch_data
[1.23, 3.45]