For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sketch Functions

Reference documentation for approximate distinct count and sketch-based aggregation functions in Apache Pinot.

Pinot supports several sketch-based algorithms for approximate distinct counting and summarization. These functions trade a small amount of accuracy for significant memory and performance savings at scale.

For exact distinct counting, see DISTINCTCOUNT.

With advanced null handling enabled, sketch-backed distinct-count functions skip null rows in regular aggregation and group-by queries, including single-value, multi-value, dictionary-encoded, and serialized-sketch inputs. Without advanced null handling, the column's configured default null value contributes to the sketch. Count-returning variants return 0 when no non-null rows contribute; raw variants preserve their function-specific empty-sketch result.

CPC Sketch

The Compressed Probability Counting (CPC) Sketch enables extremely space-efficient cardinality estimation — about 40% less space than an HLL sketch of comparable accuracy.

Function
Description

Returns approximate distinct count using CPC sketch

Returns raw CPC sketch as hex string

HyperLogLog Plus

HyperLogLogPlus (HLL++) provides approximate distinct counts with configurable precision (p, sp parameters).

Function
Description

Approximate distinct count using HLL++

Starts exact and converts to HLL++ after a threshold

HLL++ for multi-value columns

Returns serialized HLL++ sketch

Serialized HLL++ sketch for multi-value columns

UltraLogLog

The UltraLogLog Sketch from Dynatrace requires less space than HyperLogLog and provides a simpler, faster estimator. Implemented via Hash4j.

Function
Description

Approximate distinct count using ULL (default p=12)

Returns serialized ULL sketch

Tuple Sketch

The Tuple Sketch extends the Theta Sketch with additional summary values per entry, ideal for summarizing attributes like impressions or clicks.

Function
Description

Distinct count from tuple sketch

Average of summary values

Sum of summary values

With advanced null handling enabled, integer tuple-sketch aggregations skip rows whose sketch column is null. If no sketches contribute, DISTINCTCOUNTTUPLESKETCH and SUMVALUESINTEGERSUMTUPLESKETCH return NULL, DISTINCTCOUNTRAWINTEGERSUMTUPLESKETCH returns NULL, and AVGVALUEINTEGERSUMTUPLESKETCH returns NULL. Without advanced null handling, Pinot aggregates the column's default null value and preserves the legacy empty-sketch identities.

Frequency Sketches

Function
Description

Frequent items sketch for long values

Frequent items sketch for string values

With advanced null handling enabled, frequency-sketch functions skip null rows and return NULL when no values contribute. Without advanced null handling, the column's default null value contributes to the frequency estimate.

Last updated

Was this helpful?