test: add basic cases for distributed TQL (#1437)

* test: add basic cases for distributed TQL

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

* drop table

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>

---------

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2023-04-23 11:34:42 +08:00
committed by GitHub
parent c75845c570
commit 5d77ed00bb
3 changed files with 46 additions and 1 deletions

View File

@@ -114,7 +114,8 @@ impl<'a> ParserContext<'a> {
// TODO(dennis): supports multi TQL statements separated by ';'?
}
Ok(query.trim().to_string())
// remove the last ';' or tailing space if exists
Ok(query.trim().trim_end_matches(';').to_string())
} else {
Err(ParserError::ParserError(format!("{delimiter} not found",)))
}

View File

@@ -0,0 +1,32 @@
CREATE TABLE test(i DOUBLE, j TIMESTAMP TIME INDEX, k STRING PRIMARY KEY);
Affected Rows: 0
INSERT INTO test VALUES (1, 1, "a"), (1, 1, "b"), (2, 2, "a");
Affected Rows: 3
TQL EVAL (0, 10, '5s') test;
+-----+---------------------+---+
| i | j | k |
+-----+---------------------+---+
| 2.0 | 1970-01-01T00:00:05 | a |
| 2.0 | 1970-01-01T00:00:10 | a |
| 1.0 | 1970-01-01T00:00:05 | b |
| 1.0 | 1970-01-01T00:00:10 | b |
+-----+---------------------+---+
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 |
+-----+---------------------+---+
DROP TABLE test;
Affected Rows: 1

View File

@@ -0,0 +1,12 @@
CREATE TABLE test(i DOUBLE, j TIMESTAMP TIME INDEX, k STRING PRIMARY KEY);
-- insert two points at 1ms and one point at 2ms
INSERT INTO test VALUES (1, 1, "a"), (1, 1, "b"), (2, 2, "a");
-- evaluate at 0s, 5s and 10s. No point at 0s.
TQL EVAL (0, 10, '5s') test;
-- the point at 1ms will be shadowed by the point at 2ms
TQL EVAL (0, 10, '5s') test{k="a"};
DROP TABLE test;