Share via


tuple_intersection_agg_double aggregate function

Applies to: check marked yes Databricks Runtime 18.1 and above

Computes the intersection of multiple TupleSketch binary representations with double summaries. Returns a sketch containing only keys common to all input sketches.

Syntax

tuple_intersection_agg_double ( sketch [, mode ] )

Arguments

  • sketch: A TupleSketch in binary format with double summaries (such as from tuple_sketch_agg_double).
  • mode: An optional STRING literal specifying the aggregation mode for combining duplicate key summaries. Valid values: 'sum', 'min', 'max', 'alwaysone'. The default is 'sum'.

Returns

A BINARY value containing the intersected TupleSketch with double summaries.

Notes

  • NULL input sketches are ignored during aggregation.
  • The result contains only keys that appear in all input sketches.
  • For intersecting exactly two sketches, use the scalar tuple_intersection_double function.

Error messages

Examples

-- Find keys common to all sketches
> SELECT tuple_sketch_estimate_double(tuple_intersection_agg_double(sketch)) FROM (
    SELECT tuple_sketch_agg_double(key, summary) as sketch FROM VALUES (1, 5.0D), (2, 10.0D), (3, 15.0D) tab(key, summary)
    UNION ALL
    SELECT tuple_sketch_agg_double(key, summary) as sketch FROM VALUES (2, 3.0D), (3, 7.0D), (4, 12.0D) tab(key, summary)
  );
2.0