Pular para o conteúdo principal

kll_sketch_get_rank_double function

Applies to: check marked yes Databricks Runtime 18.0 and later

Estimates the normalized rank (0.0 to 1.0) of a given value in a double KLL sketch.

Syntax

kll_sketch_get_rank_double ( sketch, value )

Arguments

  • sketch: A BINARY expression containing a serialized DOUBLE KLL sketch.
  • value: A DOUBLE expression or ARRAY<DOUBLE> of values to find ranks for.

Returns

  • If value is DOUBLE: returns a DOUBLE between 0.0 and 1.0 representing the normalized rank.
  • If value is ARRAY<DOUBLE>: returns ARRAY<DOUBLE> with ranks for each value.

Notes

  • The rank represents the fraction of values in the sketch that are less than or equal to the given value.
  • Returns 0.0 if all sketch values are greater than the input value.
  • Returns 1.0 if all sketch values are less than or equal to the input value.

Examples

SQL
> WITH sketch_data AS (
SELECT kll_sketch_agg_double(value) AS sketch
FROM VALUES (1.0), (2.0), (3.0) AS T(value)
)
SELECT kll_sketch_get_rank_double(sketch, array(1.5, 2.5)) FROM sketch_data
[0.33, 0.66]