DATASKETCHES_HLL

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow functions

Returns an approximation of the distinct cardinality of the input (that is, DATASKETCHES_HLL(col1) returns an approximation of COUNT(DISTINCT col1)). 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.

Syntax

supportedpartialnot supportednot scored

Aggregate function

DATASKETCHES_HLL( [ DISTINCT ] <expr1> [ , <max_log_k> ] )

Window function

DATASKETCHES_HLL( [ DISTINCT ] <expr1> [ , <max_log_k> ] )
  OVER ( [ PARTITION BY <expr2> ] )

Parameters

NameRequiredDescription
expr1requiredThe expression for which you want to know the number of distinct values.
max_log_koptionalThe maximum value, in log2, of K to initialize the datasketches HLL object. Specify an INTEGER value between 4 and 21, inclusive. For more information, see the Apache DataSketches documentation. Default: 12
expr2optionalThe optional expression used to group rows into partitions.

Returns

The function returns a value of type DOUBLE. If the input is empty, the output is 0.0.

Usage notes

See also