mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-01-13 08:43:00 +00:00
* feat: add __schema__ tag for promql parser * feat: disable matcher op other than equals * test: add more test to ensure context getting reset * test: add integration test * test: refactor tests * refactor: remove duplicated test code * refactor: update according to review comments * test: add sqlness test for cross schema scenario --------- Co-authored-by: Ruihang Xia <waynestxia@gmail.com>
135 lines
4.0 KiB
Plaintext
135 lines
4.0 KiB
Plaintext
CREATE TABLE test(i DOUBLE, j TIMESTAMP TIME INDEX, k STRING PRIMARY KEY);
|
|
|
|
Affected Rows: 0
|
|
|
|
-- insert two points at 1ms and one point at 2ms
|
|
INSERT INTO test VALUES (1, 1, "a"), (1, 1, "b"), (2, 2, "a");
|
|
|
|
Affected Rows: 3
|
|
|
|
-- SQLNESS SORT_RESULT 2 1
|
|
-- evaluate at 0s, 5s and 10s. No point at 0s.
|
|
TQL EVAL (0, 10, '5s') test;
|
|
|
|
+-----+---------------------+---+
|
|
| i | j | k |
|
|
+-----+---------------------+---+
|
|
| 1.0 | 1970-01-01T00:00:05 | b |
|
|
| 1.0 | 1970-01-01T00:00:10 | b |
|
|
| 2.0 | 1970-01-01T00:00:05 | a |
|
|
| 2.0 | 1970-01-01T00:00:10 | a |
|
|
+-----+---------------------+---+
|
|
|
|
-- SQLNESS SORT_RESULT 2 1
|
|
TQL EVAL (0, 10, '5s') {__name__="test"};
|
|
|
|
+-----+---------------------+---+
|
|
| i | j | k |
|
|
+-----+---------------------+---+
|
|
| 1.0 | 1970-01-01T00:00:05 | b |
|
|
| 1.0 | 1970-01-01T00:00:10 | b |
|
|
| 2.0 | 1970-01-01T00:00:05 | a |
|
|
| 2.0 | 1970-01-01T00:00:10 | a |
|
|
+-----+---------------------+---+
|
|
|
|
-- SQLNESS SORT_RESULT 2 1
|
|
TQL EVAL (0, 10, '5s') test{__schema__="public"};
|
|
|
|
+-----+---------------------+---+
|
|
| i | j | k |
|
|
+-----+---------------------+---+
|
|
| 1.0 | 1970-01-01T00:00:05 | b |
|
|
| 1.0 | 1970-01-01T00:00:10 | b |
|
|
| 2.0 | 1970-01-01T00:00:05 | a |
|
|
| 2.0 | 1970-01-01T00:00:10 | a |
|
|
+-----+---------------------+---+
|
|
|
|
-- SQLNESS SORT_RESULT 2 1
|
|
TQL EVAL (0, 10, '5s') test{__schema__="greptime_private"};
|
|
|
|
Error: 4001(TableNotFound), Table not found: greptime.greptime_private.test
|
|
|
|
-- SQLNESS SORT_RESULT 2 1
|
|
TQL EVAL (0, 10, '5s') {__name__="test", __field__="i"};
|
|
|
|
+-----+---+---------------------+
|
|
| i | k | j |
|
|
+-----+---+---------------------+
|
|
| 1.0 | b | 1970-01-01T00:00:05 |
|
|
| 1.0 | b | 1970-01-01T00:00:10 |
|
|
| 2.0 | a | 1970-01-01T00:00:05 |
|
|
| 2.0 | a | 1970-01-01T00:00:10 |
|
|
+-----+---+---------------------+
|
|
|
|
-- NOT SUPPORTED: `__name__` matcher without equal condition
|
|
TQL EVAL (0, 10, '5s') {__name__!="test"};
|
|
|
|
Error: 2000(InvalidSyntax), vector selector must contain at least one non-empty matcher
|
|
|
|
-- the point at 1ms will be shadowed by the point at 2ms
|
|
TQL EVAL (0, 10, '5s') test{k="a"};
|
|
|
|
+-----+---------------------+---+
|
|
| i | j | k |
|
|
+-----+---------------------+---+
|
|
| 2.0 | 1970-01-01T00:00:05 | a |
|
|
| 2.0 | 1970-01-01T00:00:10 | a |
|
|
+-----+---------------------+---+
|
|
|
|
-- 'lookback' parameter is not fully supported, the test has to be updated
|
|
TQL EVAL (0, 10, '1s', '2s') test{k="a"};
|
|
|
|
+-----+---------------------+---+
|
|
| i | j | k |
|
|
+-----+---------------------+---+
|
|
| 2.0 | 1970-01-01T00:00:01 | a |
|
|
| 2.0 | 1970-01-01T00:00:02 | a |
|
|
| 2.0 | 1970-01-01T00:00:03 | a |
|
|
| 2.0 | 1970-01-01T00:00:04 | a |
|
|
| 2.0 | 1970-01-01T00:00:05 | a |
|
|
| 2.0 | 1970-01-01T00:00:06 | a |
|
|
| 2.0 | 1970-01-01T00:00:07 | a |
|
|
| 2.0 | 1970-01-01T00:00:08 | a |
|
|
| 2.0 | 1970-01-01T00:00:09 | a |
|
|
| 2.0 | 1970-01-01T00:00:10 | a |
|
|
+-----+---------------------+---+
|
|
|
|
TQL EVAL ('1970-01-01T00:00:00'::timestamp, '1970-01-01T00:00:00'::timestamp + '10 seconds'::interval, '1s') test{k="a"};
|
|
|
|
+-----+---------------------+---+
|
|
| i | j | k |
|
|
+-----+---------------------+---+
|
|
| 2.0 | 1970-01-01T00:00:01 | a |
|
|
| 2.0 | 1970-01-01T00:00:02 | a |
|
|
| 2.0 | 1970-01-01T00:00:03 | a |
|
|
| 2.0 | 1970-01-01T00:00:04 | a |
|
|
| 2.0 | 1970-01-01T00:00:05 | a |
|
|
| 2.0 | 1970-01-01T00:00:06 | a |
|
|
| 2.0 | 1970-01-01T00:00:07 | a |
|
|
| 2.0 | 1970-01-01T00:00:08 | a |
|
|
| 2.0 | 1970-01-01T00:00:09 | a |
|
|
| 2.0 | 1970-01-01T00:00:10 | a |
|
|
+-----+---------------------+---+
|
|
|
|
TQL EVAL (now() - now(), now() - (now() - '10 seconds'::interval), '1s') test{k="a"};
|
|
|
|
+-----+---------------------+---+
|
|
| i | j | k |
|
|
+-----+---------------------+---+
|
|
| 2.0 | 1970-01-01T00:00:01 | a |
|
|
| 2.0 | 1970-01-01T00:00:02 | a |
|
|
| 2.0 | 1970-01-01T00:00:03 | a |
|
|
| 2.0 | 1970-01-01T00:00:04 | a |
|
|
| 2.0 | 1970-01-01T00:00:05 | a |
|
|
| 2.0 | 1970-01-01T00:00:06 | a |
|
|
| 2.0 | 1970-01-01T00:00:07 | a |
|
|
| 2.0 | 1970-01-01T00:00:08 | a |
|
|
| 2.0 | 1970-01-01T00:00:09 | a |
|
|
| 2.0 | 1970-01-01T00:00:10 | a |
|
|
+-----+---------------------+---+
|
|
|
|
DROP TABLE test;
|
|
|
|
Affected Rows: 0
|
|
|