Files
greptimedb/tests/cases/standalone/common/aggregate/hll.result
Ruihang Xia 7bd108e2be feat: impl hll_state, hll_merge and hll_calc for incremental distinct counting (#5579)
* basic impl

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* more tests

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* sqlness test

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* fix clippy

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* update with more test and logs

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* impl

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* impl merge fn

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* rename function names

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
2025-02-24 19:07:37 +00:00

85 lines
1.7 KiB
Plaintext

CREATE TABLE test_hll (
`id` INT PRIMARY KEY,
`value` STRING,
`ts` timestamp time index default now()
);
Affected Rows: 0
INSERT INTO test_hll (`id`, `value`) VALUES
(1, "a"),
(2, "b"),
(5, "e"),
(6, "f"),
(7, "g"),
(8, "h"),
(9, "i"),
(10, "j"),
(11, "i"),
(12, "j"),
(13, "i"),
(14, "n"),
(15, "o");
Affected Rows: 13
select hll_count(hll(`value`)) from test_hll;
+--------------------------------+
| hll_count(hll(test_hll.value)) |
+--------------------------------+
| 10 |
+--------------------------------+
INSERT INTO test_hll (`id`, `value`) VALUES
(16, "b"),
(17, "i"),
(18, "j"),
(19, "s"),
(20, "t");
Affected Rows: 5
select hll_count(hll(`value`)) from test_hll;
+--------------------------------+
| hll_count(hll(test_hll.value)) |
+--------------------------------+
| 12 |
+--------------------------------+
create table test_hll_merge (
`id` INT PRIMARY KEY,
`state` BINARY,
`ts` timestamp time index default now()
);
Affected Rows: 0
insert into test_hll_merge (`id`, `state`)
select 1, hll(`value`) from test_hll;
Affected Rows: 1
insert into test_hll_merge (`id`, `state`)
select 2, hll(`value`) from test_hll;
Affected Rows: 1
select hll_count(hll_merge(`state`)) from test_hll_merge;
+--------------------------------------------+
| hll_count(hll_merge(test_hll_merge.state)) |
+--------------------------------------------+
| 12 |
+--------------------------------------------+
drop table test_hll;
Affected Rows: 0
drop table test_hll_merge;
Affected Rows: 0