mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-10 23:32: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>
68 lines
2.8 KiB
Plaintext
68 lines
2.8 KiB
Plaintext
CREATE TABLE http_requests (
|
|
ts timestamp(3) time index,
|
|
host STRING,
|
|
idc STRING,
|
|
val BIGINT,
|
|
PRIMARY KEY(host, idc),
|
|
);
|
|
|
|
Affected Rows: 0
|
|
|
|
INSERT INTO TABLE http_requests VALUES
|
|
(0, 'host1', "idc1", 200),
|
|
(0, 'host2', "idc1", 200),
|
|
(0, 'host3', "idc2", 200),
|
|
(0, 'host4', "idc2", 401),
|
|
(5000, 'host1', "idc1", 404),
|
|
(5000, 'host2', "idc1", 401),
|
|
(5000, 'host3', "idc2", 404),
|
|
(5000, 'host4', "idc2", 500),
|
|
(10000, 'host1', "idc1", 200),
|
|
(10000, 'host2', "idc1", 200),
|
|
(10000, 'host3', "idc2", 201),
|
|
(10000, 'host4', "idc2", 201),
|
|
(15000, 'host1', "idc1", 500),
|
|
(15000, 'host2', "idc1", 500),
|
|
(15000, 'host3', "idc2", 500),
|
|
(15000, 'host4', "idc2", 500);
|
|
|
|
Affected Rows: 16
|
|
|
|
TQL EVAL (0, 15, '5s') count_values("status_code", http_requests);
|
|
|
|
+--------------------------+---------------------+-------------+
|
|
| count(http_requests.val) | ts | status_code |
|
|
+--------------------------+---------------------+-------------+
|
|
| 3 | 1970-01-01T00:00:00 | 200 |
|
|
| 1 | 1970-01-01T00:00:00 | 401 |
|
|
| 1 | 1970-01-01T00:00:05 | 401 |
|
|
| 2 | 1970-01-01T00:00:05 | 404 |
|
|
| 1 | 1970-01-01T00:00:05 | 500 |
|
|
| 2 | 1970-01-01T00:00:10 | 200 |
|
|
| 2 | 1970-01-01T00:00:10 | 201 |
|
|
| 4 | 1970-01-01T00:00:15 | 500 |
|
|
+--------------------------+---------------------+-------------+
|
|
|
|
TQL EVAL (0, 15, '5s') count_values("status_code", http_requests) by (idc);
|
|
|
|
+--------------------------+------+---------------------+-------------+
|
|
| count(http_requests.val) | idc | ts | status_code |
|
|
+--------------------------+------+---------------------+-------------+
|
|
| 2 | idc1 | 1970-01-01T00:00:00 | 200 |
|
|
| 1 | idc1 | 1970-01-01T00:00:05 | 401 |
|
|
| 1 | idc1 | 1970-01-01T00:00:05 | 404 |
|
|
| 2 | idc1 | 1970-01-01T00:00:10 | 200 |
|
|
| 2 | idc1 | 1970-01-01T00:00:15 | 500 |
|
|
| 1 | idc2 | 1970-01-01T00:00:00 | 200 |
|
|
| 1 | idc2 | 1970-01-01T00:00:00 | 401 |
|
|
| 1 | idc2 | 1970-01-01T00:00:05 | 404 |
|
|
| 1 | idc2 | 1970-01-01T00:00:05 | 500 |
|
|
| 2 | idc2 | 1970-01-01T00:00:10 | 201 |
|
|
| 2 | idc2 | 1970-01-01T00:00:15 | 500 |
|
|
+--------------------------+------+---------------------+-------------+
|
|
|
|
DROP TABLE http_requests;
|
|
|
|
Affected Rows: 0
|
|
|