mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-08 06:12:55 +00:00
feat: implement count_hash aggr function (#6342)
* feat: implement count_hash aggr function Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * sqlness case Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * change copyright year Signed-off-by: Ruihang Xia <waynestxia@gmail.com> * review changes Signed-off-by: Ruihang Xia <waynestxia@gmail.com> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
60
tests/cases/standalone/common/function/count_hash.result
Normal file
60
tests/cases/standalone/common/function/count_hash.result
Normal file
@@ -0,0 +1,60 @@
|
||||
create table
|
||||
t (
|
||||
ts timestamp time index,
|
||||
`id` int,
|
||||
`name` string,
|
||||
PRIMARY KEY (`id`),
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
insert into
|
||||
t (ts, `id`, `name`)
|
||||
values
|
||||
(1, 1, 'a'),
|
||||
(2, 2, 'b'),
|
||||
(3, 3, 'c'),
|
||||
(4, 4, 'd');
|
||||
|
||||
Affected Rows: 4
|
||||
|
||||
select
|
||||
count_hash (`id`)
|
||||
from
|
||||
t;
|
||||
|
||||
+------------------+
|
||||
| count_hash(t.id) |
|
||||
+------------------+
|
||||
| 4 |
|
||||
+------------------+
|
||||
|
||||
select
|
||||
count_hash (`id`)
|
||||
from
|
||||
t
|
||||
group by
|
||||
`name`;
|
||||
|
||||
+------------------+
|
||||
| count_hash(t.id) |
|
||||
+------------------+
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
| 1 |
|
||||
+------------------+
|
||||
|
||||
select
|
||||
count_hash (`id`, `name`)
|
||||
from
|
||||
t
|
||||
group by
|
||||
ts;
|
||||
|
||||
Error: 3001(EngineExecuteQuery), This feature is not implemented: count_hash with multiple arguments
|
||||
|
||||
drop table t;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
36
tests/cases/standalone/common/function/count_hash.sql
Normal file
36
tests/cases/standalone/common/function/count_hash.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
create table
|
||||
t (
|
||||
ts timestamp time index,
|
||||
`id` int,
|
||||
`name` string,
|
||||
PRIMARY KEY (`id`),
|
||||
);
|
||||
|
||||
insert into
|
||||
t (ts, `id`, `name`)
|
||||
values
|
||||
(1, 1, 'a'),
|
||||
(2, 2, 'b'),
|
||||
(3, 3, 'c'),
|
||||
(4, 4, 'd');
|
||||
|
||||
select
|
||||
count_hash (`id`)
|
||||
from
|
||||
t;
|
||||
|
||||
select
|
||||
count_hash (`id`)
|
||||
from
|
||||
t
|
||||
group by
|
||||
`name`;
|
||||
|
||||
select
|
||||
count_hash (`id`, `name`)
|
||||
from
|
||||
t
|
||||
group by
|
||||
ts;
|
||||
|
||||
drop table t;
|
||||
Reference in New Issue
Block a user