Skip to main content

HLL_RAW_AGG

Description

The HLL_RAW_AGG function is an aggregate function mainly used to merge multiple HyperLogLog data structures into one.

Alias

  • HLL_UNION

Syntax

HLL_RAW_AGG(<hll>)
HLL_UNION(<hll>)

Parameters

ParameterDescription
<hll>The expression to be calculated, type HLL supported.

Return Value

Returns the aggregated HLL type. If there is no valid data in the group, returns HLL_EMPTY.

Example

-- setup
create table test_uv(
id int,
uv_set string
) distributed by hash(id) buckets 1
properties ("replication_num"="1");
insert into test_uv values
(1, ('a')),
(1, ('b')),
(2, ('c')),
(2, ('d')),
(3, null);
select HLL_CARDINALITY(HLL_RAW_AGG(hll_hash(uv_set))) from test_uv;
+------------------------------------------------+
| HLL_CARDINALITY(HLL_RAW_AGG(hll_hash(uv_set))) |
+------------------------------------------------+
| 4 |
+------------------------------------------------+
select HLL_CARDINALITY(HLL_RAW_AGG(hll_hash(uv_set))) from test_uv where uv_set is null;
+------------------------------------------------+
| HLL_CARDINALITY(HLL_RAW_AGG(hll_hash(uv_set))) |
+------------------------------------------------+
| 0 |
+------------------------------------------------+