mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-06 05:12:54 +00:00
feat: implement uddsketch function to calculate percentile (#5574)
* 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> --------- Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
58
tests/cases/standalone/common/aggregate/uddsketch.result
Normal file
58
tests/cases/standalone/common/aggregate/uddsketch.result
Normal file
@@ -0,0 +1,58 @@
|
||||
CREATE TABLE test_uddsketch (
|
||||
`id` INT PRIMARY KEY,
|
||||
`value` DOUBLE,
|
||||
`ts` timestamp time index default now()
|
||||
);
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
INSERT INTO test_uddsketch (`id`, `value`) VALUES
|
||||
(1, 10.0),
|
||||
(2, 20.0),
|
||||
(3, 30.0),
|
||||
(4, 40.0),
|
||||
(5, 50.0),
|
||||
(6, 60.0),
|
||||
(7, 70.0),
|
||||
(8, 80.0),
|
||||
(9, 90.0),
|
||||
(10, 100.0);
|
||||
|
||||
Affected Rows: 10
|
||||
|
||||
select uddsketch_calc(0.1, uddsketch_state(128, 0.01, `value`)) from test_uddsketch;
|
||||
|
||||
+---------------------------------------------------------------------------------------------+
|
||||
| uddsketch_calc(Float64(0.1),uddsketch_state(Int64(128),Float64(0.01),test_uddsketch.value)) |
|
||||
+---------------------------------------------------------------------------------------------+
|
||||
| 19.886670240866184 |
|
||||
+---------------------------------------------------------------------------------------------+
|
||||
|
||||
select uddsketch_calc(0.5, uddsketch_state(128, 0.01, `value`)) from test_uddsketch;
|
||||
|
||||
+---------------------------------------------------------------------------------------------+
|
||||
| uddsketch_calc(Float64(0.5),uddsketch_state(Int64(128),Float64(0.01),test_uddsketch.value)) |
|
||||
+---------------------------------------------------------------------------------------------+
|
||||
| 59.745049810145126 |
|
||||
+---------------------------------------------------------------------------------------------+
|
||||
|
||||
select uddsketch_calc(0.75, uddsketch_state(128, 0.01, `value`)) from test_uddsketch;
|
||||
|
||||
+----------------------------------------------------------------------------------------------+
|
||||
| uddsketch_calc(Float64(0.75),uddsketch_state(Int64(128),Float64(0.01),test_uddsketch.value)) |
|
||||
+----------------------------------------------------------------------------------------------+
|
||||
| 80.648188221533 |
|
||||
+----------------------------------------------------------------------------------------------+
|
||||
|
||||
select uddsketch_calc(0.95, uddsketch_state(128, 0.01, `value`)) from test_uddsketch;
|
||||
|
||||
+----------------------------------------------------------------------------------------------+
|
||||
| uddsketch_calc(Float64(0.95),uddsketch_state(Int64(128),Float64(0.01),test_uddsketch.value)) |
|
||||
+----------------------------------------------------------------------------------------------+
|
||||
| 100.49456770856492 |
|
||||
+----------------------------------------------------------------------------------------------+
|
||||
|
||||
drop table test_uddsketch;
|
||||
|
||||
Affected Rows: 0
|
||||
|
||||
27
tests/cases/standalone/common/aggregate/uddsketch.sql
Normal file
27
tests/cases/standalone/common/aggregate/uddsketch.sql
Normal file
@@ -0,0 +1,27 @@
|
||||
CREATE TABLE test_uddsketch (
|
||||
`id` INT PRIMARY KEY,
|
||||
`value` DOUBLE,
|
||||
`ts` timestamp time index default now()
|
||||
);
|
||||
|
||||
INSERT INTO test_uddsketch (`id`, `value`) VALUES
|
||||
(1, 10.0),
|
||||
(2, 20.0),
|
||||
(3, 30.0),
|
||||
(4, 40.0),
|
||||
(5, 50.0),
|
||||
(6, 60.0),
|
||||
(7, 70.0),
|
||||
(8, 80.0),
|
||||
(9, 90.0),
|
||||
(10, 100.0);
|
||||
|
||||
select uddsketch_calc(0.1, uddsketch_state(128, 0.01, `value`)) from test_uddsketch;
|
||||
|
||||
select uddsketch_calc(0.5, uddsketch_state(128, 0.01, `value`)) from test_uddsketch;
|
||||
|
||||
select uddsketch_calc(0.75, uddsketch_state(128, 0.01, `value`)) from test_uddsketch;
|
||||
|
||||
select uddsketch_calc(0.95, uddsketch_state(128, 0.01, `value`)) from test_uddsketch;
|
||||
|
||||
drop table test_uddsketch;
|
||||
Reference in New Issue
Block a user