Skip to main content
Since 1.16.0 This is an alternate first step for approximating the number of distinct values. It provides some added convenience by using some sensible default parameters to create a hyperloglog. Use approx_count_distinct to create an intermediate aggregate from your raw data. This intermediate form can then be used by one or more accessors in this group to compute final results. Optionally, multiple such intermediate aggregate objects can be combined using rollup() before an accessor is applied.

Samples

Given a table called samples, with a column called weights, return a hyperloglog over the weights column:
SELECT toolkit_experimental.approx_count_distinct(weights) FROM samples;
Using the same data, 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;

Arguments

NameTypeDefaultRequiredDescription
valueAnyElement-The column containing the elements to count. The type must have an extended, 64-bit, hash function.

Returns

A hyperloglog object which can be passed to other hyperloglog APIs for rollups and final calculation