Applies to: Databricks SQL Databricks Runtime 13.1 and above
This function utilizes the HyperLogLog algorithm to count a probabilistic approximation of the number of unique values in a given column, and outputs the result as a binary representation known as a sketch buffer. This binary representation is suitable for persistence.
Queries can use the resulting buffers to compute approximate unique counts with the hll_sketch_estimate function.
hll_sketch_agg ( expr [, lgConfigK ] )
This function can also be invoked as a window function using the
expr: An expression of type
BINARYagainst which unique counting will occur.
lgConfigK: An optional
INTconstant between 4 and 21 inclusive with default 12. The log-base-2 of K, where K is the number of buckets or slots for the sketch.
expr is ignored.
BINARY buffer containing the HyperLogLog sketch computed as a result of consuming and aggregating all input values in the aggregation group.