Del via


tuple_sketch_summary_double function

Applies to: check marked yes Databricks Runtime 18.1 and above

Aggregates the summary values from a TupleSketch with double summaries according to the specified mode.

Syntax

tuple_sketch_summary_double ( sketch [, mode ] )

Arguments

  • sketch: A TupleSketch in binary format with double summaries.
  • mode: An optional STRING literal specifying the aggregation mode. Valid values: 'sum', 'min', 'max', 'alwaysone'. The default is 'sum'.

Returns

A DOUBLE value representing the aggregated summary across all keys in the sketch.

Notes

  • In 'sum' mode, the function returns the sum of all summary values.
  • In 'min' mode, the function returns the minimum summary value.
  • In 'max' mode, the function returns the maximum summary value.
  • In 'alwaysone' mode, the function returns the count of entries (equivalent to distinct count).

Error messages

Examples

-- Sum of all summary values
> SELECT tuple_sketch_summary_double(tuple_sketch_agg_double(key, summary)) FROM VALUES (1, 1.0D), (1, 2.0D), (2, 3.0D) tab(key, summary);
6.0