Skip to main content

theta_sketch_estimate function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 18.0 and above

Returns the estimated number of unique values from a Theta Sketch binary representation.

Syntax

theta_sketch_estimate ( sketch )

Arguments

Returns

A LONG value representing the estimated distinct count.

Notes

  • The result is rounded to the nearest integer.
  • The estimate is probabilistic; accuracy depends on the lgNomEntries parameter used when creating the sketch.

Error messages

Examples

SQL
-- Get estimated distinct count from a sketch
> SELECT theta_sketch_estimate(theta_sketch_agg(col)) FROM VALUES (1), (1), (2), (2), (3) tab(col);
3