kll_sketch_merge_double function
Applies to: Databricks Runtime 18.0 and later
Merges two compatible double KLL sketches into a single sketch.
Syntax
kll_sketch_merge_double ( sketch1, sketch2 )
Arguments
sketch1: ABINARYexpression containing a serializedDOUBLEKLL sketch.sketch2: ABINARYexpression containing a serializedDOUBLEKLL sketch.
Returns
A BINARY value containing the merged sketch.
Notes
- Both sketches must be for the same data type (double).
- The merged sketch has the same k parameter as the input sketches.
- Sketches with different k values cannot be merged.
- Useful for distributed aggregation: create sketches per partition, then merge.
Examples
SQL
> WITH s1 AS (SELECT kll_sketch_agg_double(v) AS sketch FROM VALUES (1.0), (2.0) AS T(v)),
s2 AS (SELECT kll_sketch_agg_double(v) AS sketch FROM VALUES (3.0), (4.0) AS T(v))
SELECT kll_sketch_merge_double(s1.sketch, s2.sketch) FROM s1, s2
[binary data]