HLL(HyperLogLog)
description
HLL HLL不能作为key列使用,支持在Aggregate模型、Duplicate模型和Unique模型的表中使用。在Aggregate模型表中使用时,建表时配合的聚合类型为HLL_UNION。 用户不需要指定长度和默认值。长度根据数据的聚合程度系统内控制。 并且HLL列只能通过配套的hll_union_agg、hll_raw_agg、hll_cardinality、hll_hash进行查询或使用。
HLL是模糊去重,在数据量大的情况性能优于Count Distinct。 HLL的误差通常在1%左右,有时会达到2%。
example
1. select hour, HLL_UNION_AGG(pv) over(order by hour) uv from(
2. select hour, HLL_RAW_AGG(device_id) as pv
3. from metric_table -- 查询每小时的累计UV
4. where datekey=20200622
5. group by hour order by 1
6. ) final;
keywords
1. HLL,HYPERLOGLOG
