DATASKETCHES_HLL_ACCUMULATE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow function syntax and usage

Returns the sketch at the end of aggregation. This function is a version of the HLL HyperLogLog function that can read binary sketches in the format used by Apache DataSketches. For more information, see the Apache DataSketches documentation. DATASKETCHES_HLL discards its intermediate state when the final cardinality estimate is returned. In advanced use cases, such as incremental cardinality estimation during bulk loading, you might want to keep the intermediate state. The intermediate state can later be combined (merged) with other intermediate states, or can be exported to external tools. In contrast to DATASKETCHES_HLL, DATASKETCHES_HLL_ACCUMULATE doesn’t return a cardinality estimate. Instead, it skips the final estimation step and returns the algorithm state itself. For more information, see Estimating the Number of Distinct Values.

Syntax

supportedpartialnot supportednot scored

DATASKETCHES_HLL_ACCUMULATE( [ DISTINCT ] <expr> [ , <max_log_k> ] )

Parameters

NameRequiredDescription
exprrequiredThe expression for which you want to estimate cardinality (number of distinct values). This is typically a column name, but can be a more general expression.
max_log_koptionalThe maximum value, in log2, of K for this union. Specify an INTEGER value between 4 and 21, inclusive. For more information, see the Apache DataSketches documentation. Default: 12

Returns

The function returns a BINARY value that is compatible with the Apache Datasketches library.

Usage notes

See also

Referenced by