rollup()

rollup(
    log hyperloglog
) RETURNS Hyperloglog

Returns a hyperloglog by aggregating over the union of the input elements. Since hyperloglog is designed to merge well, rollup does not compound errors. Union of hyperloglogs of different bucket size is currently not supported.

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

Required arguments

NameTypeDescription
logHyperloglogColumn of Hyperloglogs to be united.

Returns

ColumnTypeDescription
hyperloglogHyperloglogA hyperloglog containing the count of the union of the input hyperloglogs.

Sample usage

SELECT distinct_count(rollup(logs))
FROM (
    (SELECT hyperloglog(32768, v::text) logs FROM generate_series(1, 100000) v)
    UNION ALL
    (SELECT hyperloglog(32768, v::text) FROM generate_series(50000, 150000) v)
) hll;

 distinct_count 
----------------
         150147

Found an issue on this page?

Report an issue!

Keywords

Related Content