-- Create test table
CREATE TABLE t1 (
id BIGINT,
province VARCHAR(64),
age SMALLINT,
dt VARCHAR(10)
)
DUPLICATE KEY(id)
DISTRIBUTED BY HASH(id) BUCKETS 3;
-- Insert test data
INSERT INTO t1 SELECT generate_series, generate_series, generate_series % 100, "2024-07-24"
FROM table(generate_series(1, 1000));
-- Basic usage with single argument
SELECT ds_hll_accumulate(id) FROM t1;
-- With custom log_k parameter
SELECT ds_hll_accumulate(province, 20) FROM t1;
-- With both log_k and tgt_type parameters
SELECT ds_hll_accumulate(age, 12, "HLL_6") FROM t1;
-- Group by usage
SELECT dt,
ds_hll_accumulate(id),
ds_hll_accumulate(province, 20),
ds_hll_accumulate(age, 12, "HLL_6"),
ds_hll_accumulate(dt)
FROM t1
GROUP BY dt
ORDER BY 1
LIMIT 3;