Jaa


tuple_intersection_agg_integer aggregate function

Applies to: check marked yes Databricks Runtime 18.1 and above

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

Syntax

tuple_intersection_agg_integer ( sketch [, mode ] )

Arguments

  • sketch: A TupleSketch in binary format with integer summaries (such as from tuple_sketch_agg_integer).
  • 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 integer 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_integer function.

Error messages

Examples

-- Find keys common to all sketches
> SELECT tuple_sketch_estimate_integer(tuple_intersection_agg_integer(sketch)) FROM (
    SELECT tuple_sketch_agg_integer(key, summary) as sketch FROM VALUES (1, 1), (2, 2), (3, 3) tab(key, summary)
    UNION ALL
    SELECT tuple_sketch_agg_integer(key, summary) as sketch FROM VALUES (2, 2), (3, 3), (4, 4) tab(key, summary)
  );
2.0