Jaa


kll_merge_agg_float aggregate function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 18.0 and above

Consumes multiple KLL (K-Linear-Logarithmic) sketch buffers for approximate quantile estimation on single-precision floating-point data and merges them into one result buffer.

Syntax

kll_merge_agg_float ( sketch [, k ] )

Arguments

  • sketch: A KLL sketch in binary format (such as from kll_sketch_agg_float).
  • k: An optional INTEGER literal controlling sketch accuracy. Must be between 8 and 65535. The default is 200. Higher values provide better accuracy but use more memory.

Returns

A BINARY value containing the merged serialized KLL sketch for single-precision floating-point data.

Notes

  • When k is not specified, the merged sketch adopts the k value from the first input sketch.
  • The merge operation handles input sketches with different k values.
  • NULL values are ignored during aggregation.
  • Use this function when merging multiple sketches in an aggregation context. For merging exactly two sketches, use the scalar kll_sketch_merge_float function instead.

Error messages

Examples

-- Merge sketches with default k=200
> SELECT kll_sketch_get_n_float(kll_merge_agg_float(sketch))
  FROM (
    SELECT kll_sketch_agg_float(col) AS sketch
    FROM VALUES (1), (2), (3) AS tab(col)
    UNION ALL
    SELECT kll_sketch_agg_float(col) AS sketch
    FROM VALUES (4), (5), (6) AS tab(col)
  ) t;
6.0