mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-14 01:02:55 +00:00
* feat(promql): supports quantile * fix: merge_batch * chore: sqlness test * test: unit tests * feat: implements count_values * fix: typo * refactor: planner * chore: apply review suggestions --------- Co-authored-by: Yingwen <realevenyag@gmail.com>
72 lines
2.3 KiB
Plaintext
72 lines
2.3 KiB
Plaintext
CREATE TABLE test (
|
|
ts timestamp(3) time index,
|
|
host STRING,
|
|
idc STRING,
|
|
val BIGINT,
|
|
PRIMARY KEY(host, idc),
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO TABLE test VALUES
|
|
(0, 'host1', "idc1", 1),
|
|
(0, 'host2', "idc1", 2),
|
|
(0, 'host3', "idc2", 3),
|
|
(0, 'host4', "idc2", 4),
|
|
(5000, 'host1', "idc1", 5),
|
|
(5000, 'host2', "idc1", 6),
|
|
(5000, 'host3', "idc2", 7),
|
|
(5000, 'host4', "idc2", 8),
|
|
(10000, 'host1', "idc1", 9),
|
|
(10000, 'host2', "idc1", 10),
|
|
(10000, 'host3', "idc2", 11),
|
|
(10000, 'host4', "idc2", 12),
|
|
(15000, 'host1', "idc1", 13),
|
|
(15000, 'host2', "idc1", 14),
|
|
(15000, 'host3', "idc2", 15),
|
|
(15000, 'host4', "idc2", 16);
|
|
|
|
Affected Rows: 16
|
|
|
|
TQL EVAL (0, 15, '5s') quantile(0.5, test);
|
|
|
|
+---------------------+--------------------+
|
|
| ts | quantile(test.val) |
|
|
+---------------------+--------------------+
|
|
| 1970-01-01T00:00:00 | 2.5 |
|
|
| 1970-01-01T00:00:05 | 6.5 |
|
|
| 1970-01-01T00:00:10 | 10.5 |
|
|
| 1970-01-01T00:00:15 | 14.5 |
|
|
+---------------------+--------------------+
|
|
|
|
TQL EVAL (0, 15, '5s') quantile(0.5, test) by (idc);
|
|
|
|
+------+---------------------+--------------------+
|
|
| idc | ts | quantile(test.val) |
|
|
+------+---------------------+--------------------+
|
|
| idc1 | 1970-01-01T00:00:00 | 1.5 |
|
|
| idc1 | 1970-01-01T00:00:05 | 5.5 |
|
|
| idc1 | 1970-01-01T00:00:10 | 9.5 |
|
|
| idc1 | 1970-01-01T00:00:15 | 13.5 |
|
|
| idc2 | 1970-01-01T00:00:00 | 3.5 |
|
|
| idc2 | 1970-01-01T00:00:05 | 7.5 |
|
|
| idc2 | 1970-01-01T00:00:10 | 11.5 |
|
|
| idc2 | 1970-01-01T00:00:15 | 15.5 |
|
|
+------+---------------------+--------------------+
|
|
|
|
TQL EVAL (0, 15, '5s') quantile(0.5, sum(test) by (idc));
|
|
|
|
+---------------------+-------------------------+
|
|
| ts | quantile(sum(test.val)) |
|
|
+---------------------+-------------------------+
|
|
| 1970-01-01T00:00:00 | 5.0 |
|
|
| 1970-01-01T00:00:05 | 13.0 |
|
|
| 1970-01-01T00:00:10 | 21.0 |
|
|
| 1970-01-01T00:00:15 | 29.0 |
|
|
+---------------------+-------------------------+
|
|
|
|
DROP TABLE test;
|
|
|
|
Affected Rows: 0
|
|
|