hyperloglog()

The hyperloglog function constructs and returns a hyperloglog with at least the specified number of buckets over the given values.

For more information about approximate count distinct functions, see the hyperfunctions documentation.

Required Arguments

NameTypeDescription
bucketsintegerNumber of buckets in the digest. Rounded up to the next power of 2, must be between 16 and 2^18.
valueAnyElementColumn to count distinct elements. The type must have an extended, 64-bit, hash function.

Increasing the buckets argument usually provides more accuracy at the expense of more storage.

Returns

ColumnTypeDescription
hyperlogloghyperloglogA hyperloglog object which can be passed to other hyperloglog APIs.

Sample Usage

This examples assumes you have a table called samples, that contains a column called weights that holds DOUBLE PRECISION values. This command returns a digest over that column:

SELECT hyperloglog(64, weights) FROM samples;

Alternatively, you can build a view from the aggregate that you can pass to other tdigest functions:

CREATE VIEW digest AS SELECT hyperloglog(64, data) FROM samples;

Found an issue on this page?

Report an issue!

Related Content