Skip to main content

HLL (HyperLogLog)

Description​

HLL

HLL columns must be nonnullable, non-key columns. They can be used in Aggregate, Duplicate Key, and Unique Key tables. In an Aggregate table, use the HLL_UNION aggregation type. The user does not need to specify the length and default value. The length is controlled within the system according to the degree of data aggregation. And HLL columns can only be queried or used through the matching hll_union_agg, hll_raw_agg, hll_cardinality, and hll_hash.

HLL estimates the number of distinct elements. It trades exact results for a compact aggregation state. Accuracy and performance depend on the input data and workload. The upstream reference describes typical errors around 1%, sometimes 2%. These figures are estimates, not an error bound or a Cloud benchmark.

example​

select hour, HLL_UNION_AGG(pv) over(order by hour) uv from(
select hour, HLL_RAW_AGG(device_id) as pv
from metric_table -- Query the accumulated UV per hour
where datekey=20200922
group by hour order by 1
) final;

keywords​

HLL,HYPERLOGLOG