Del via


tuple_difference_double function

Applies to: check marked yes Databricks Runtime 18.1 and above

Computes the set difference (A minus B) of two TupleSketch binary representations with double summaries. The returned sketch contains only keys that appear in the first sketch but not in the second.

Syntax

tuple_difference_double ( first, second )

Arguments

  • first: A TupleSketch in binary format with double summaries (set A).
  • second: A TupleSketch in binary format with double summaries (set B).

Returns

A BINARY value containing the TupleSketch representing the set difference (A - B).

Notes

  • The operation is NOT commutative: tuple_difference_double(A, B) ≠ tuple_difference_double(B, A).
  • The result contains keys from the first sketch that do not appear in the second.
  • Summary values from the first sketch are preserved for keys in the result.

Error messages

Examples

> SELECT tuple_sketch_estimate_double(
    tuple_difference_double(
      tuple_sketch_agg_double(col1, val1),
      tuple_sketch_agg_double(col2, val2)
    )
  ) FROM VALUES (5, 5.0D, 4, 4.0D), (1, 1.0D, 4, 4.0D), (2, 2.0D, 5, 5.0D), (3, 3.0D, 1, 1.0D) tab(col1, val1, col2, val2);
2.0