approx_count_distinct()

The approx_count_distinct function constructs and returns a hyperloglog with a default size appropriate for the majority of use cases.

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

Required arguments

NameTypeDescription
valueAnyElementColumn to count distinct elements. The type must have an extended, 64-bit, hash function.

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 toolkit_experimental.approx_count_distinct(weights) FROM samples;

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

CREATE VIEW hll AS SELECT toolkit_experimental.approx_count_distinct(data) FROM samples;

Found an issue on this page?

Report an issue!

Related Content