add window view test

This commit is contained in:
Vxider 2020-01-14 11:09:48 +08:00
parent d85ca7576c
commit 68666b11a7
10 changed files with 191 additions and 0 deletions

View File

@ -0,0 +1,12 @@
--TUMBLE--
('2020-01-09 00:00:00','2020-01-10 00:00:00')
2020-01-09 00:00:00
2020-01-09 00:00:00
2020-01-10 00:00:00
2020-01-10 00:00:00
--HOP--
[('2020-01-07 00:00:00','2020-01-10 00:00:00'),('2020-01-08 00:00:00','2020-01-11 00:00:00'),('2020-01-09 00:00:00','2020-01-12 00:00:00')]
2020-01-07 00:00:00
2020-01-07 00:00:00
2020-01-12 00:00:00
2020-01-12 00:00:00

View File

@ -0,0 +1,13 @@
SELECT '--TUMBLE--';
SELECT TUMBLE(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY);
SELECT TUMBLE_START(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY);
SELECT TUMBLE_START(TUMBLE(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY));
SELECT TUMBLE_END(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY);
SELECT TUMBLE_END(TUMBLE(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY));
SELECT '--HOP--';
SELECT HOP(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY, INTERVAL '3' DAY);
SELECT HOP_START(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY, INTERVAL '3' DAY);
SELECT HOP_START(HOP(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY, INTERVAL '3' DAY));
SELECT HOP_END(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY, INTERVAL '3' DAY);
SELECT HOP_END(HOP(toDateTime('2020-01-09 12:00:01'), INTERVAL '1' DAY, INTERVAL '3' DAY));

View File

@ -0,0 +1,6 @@
1 2020-01-09 12:00:00 2020-01-09 12:00:05
1 2020-01-09 12:00:05 2020-01-09 12:00:10
1 2020-01-09 12:00:15 2020-01-09 12:00:20
1 2020-01-09 12:00:10 2020-01-09 12:00:15
1 2020-01-09 12:00:20 2020-01-09 12:00:25
1 2020-01-09 12:00:35 2020-01-09 12:00:40

View File

@ -0,0 +1,25 @@
SET allow_experimental_window_view = 1;
DROP TABLE IF EXISTS test.wv;
DROP TABLE IF EXISTS test.mt;
CREATE TABLE test.mt(a Int32, timestamp DateTime) Engine=MergeTree order by tuple();
CREATE WINDOW VIEW test.wv AS SELECT count(a), TUMBLE_START(wid) as w_start, TUMBLE_END(wid) as w_end FROM test.mt group by TUMBLE(timestamp, INTERVAL '5' SECOND) as wid;
INSERT INTO test.mt VALUES (1, toDateTime('2020-01-09 12:00:01'));
INSERT INTO test.mt VALUES (2, toDateTime('2020-01-09 12:00:05'));
WATCH test.wv LIMIT 1;
INSERT INTO test.mt VALUES (3, toDateTime('2020-01-09 12:00:10'));
INSERT INTO test.mt VALUES (4, toDateTime('2020-01-09 12:00:15'));
WATCH test.wv LIMIT 1;
INSERT INTO test.mt VALUES (5, toDateTime('2020-01-09 12:00:20'));
INSERT INTO test.mt VALUES (6, toDateTime('2020-01-09 12:00:35'));
WATCH test.wv LIMIT 1;
DROP TABLE test.wv;
DROP TABLE test.mt;

View File

@ -0,0 +1,29 @@
1 2020-01-09 11:59:59 2020-01-09 12:00:04
1 2020-01-09 12:00:00 2020-01-09 12:00:05
1 2020-01-09 12:00:04 2020-01-09 12:00:09
1 2020-01-09 11:59:58 2020-01-09 12:00:03
1 2020-01-09 11:59:57 2020-01-09 12:00:02
1 2020-01-09 12:00:05 2020-01-09 12:00:10
1 2020-01-09 12:00:02 2020-01-09 12:00:07
2 2020-01-09 12:00:01 2020-01-09 12:00:06
1 2020-01-09 12:00:03 2020-01-09 12:00:08
1 2020-01-09 12:00:15 2020-01-09 12:00:20
1 2020-01-09 12:00:08 2020-01-09 12:00:13
1 2020-01-09 12:00:12 2020-01-09 12:00:17
1 2020-01-09 12:00:07 2020-01-09 12:00:12
1 2020-01-09 12:00:10 2020-01-09 12:00:15
1 2020-01-09 12:00:14 2020-01-09 12:00:19
1 2020-01-09 12:00:09 2020-01-09 12:00:14
1 2020-01-09 12:00:13 2020-01-09 12:00:18
1 2020-01-09 12:00:11 2020-01-09 12:00:16
1 2020-01-09 12:00:06 2020-01-09 12:00:11
1 2020-01-09 12:00:32 2020-01-09 12:00:37
1 2020-01-09 12:00:20 2020-01-09 12:00:25
1 2020-01-09 12:00:16 2020-01-09 12:00:21
1 2020-01-09 12:00:31 2020-01-09 12:00:36
1 2020-01-09 12:00:34 2020-01-09 12:00:39
1 2020-01-09 12:00:33 2020-01-09 12:00:38
1 2020-01-09 12:00:35 2020-01-09 12:00:40
1 2020-01-09 12:00:18 2020-01-09 12:00:23
1 2020-01-09 12:00:19 2020-01-09 12:00:24
1 2020-01-09 12:00:17 2020-01-09 12:00:22

View File

@ -0,0 +1,22 @@
SET allow_experimental_window_view = 1;
DROP TABLE IF EXISTS test.wv;
DROP TABLE IF EXISTS test.mt;
CREATE TABLE test.mt(a Int32, timestamp DateTime) Engine=MergeTree order by tuple();
CREATE WINDOW VIEW test.wv AS SELECT count(a), HOP_START(wid) as w_start, HOP_END(wid) as w_end FROM test.mt group by HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '5' SECOND) as wid;
INSERT INTO test.mt VALUES (1, toDateTime('2020-01-09 12:00:01'));
INSERT INTO test.mt VALUES (2, toDateTime('2020-01-09 12:00:05'));
WATCH test.wv LIMIT 1;
INSERT INTO test.mt VALUES (3, toDateTime('2020-01-09 12:00:10'));
INSERT INTO test.mt VALUES (4, toDateTime('2020-01-09 12:00:15'));
WATCH test.wv LIMIT 1;
INSERT INTO test.mt VALUES (5, toDateTime('2020-01-09 12:00:20'));
INSERT INTO test.mt VALUES (6, toDateTime('2020-01-09 12:00:35'));
WATCH test.wv LIMIT 1;
DROP TABLE test.wv;
DROP TABLE test.mt;

View File

@ -0,0 +1,7 @@
0
1 2020-01-09 12:00:00 2020-01-09 12:00:05
1 2020-01-09 12:00:05 2020-01-09 12:00:10
1 2020-01-09 12:00:10 2020-01-09 12:00:15
1 2020-01-09 12:00:15 2020-01-09 12:00:20
1 2020-01-09 12:00:20 2020-01-09 12:00:25
1 2020-01-09 12:00:35 2020-01-09 12:00:40

View File

@ -0,0 +1,23 @@
SET allow_experimental_window_view = 1;
DROP TABLE IF EXISTS test.wv;
DROP TABLE IF EXISTS test.mt;
DROP TABLE IF EXISTS test.dst;
CREATE TABLE test.mt(a Int32, timestamp DateTime) Engine=MergeTree order by tuple();
CREATE TABLE test.dst(count UInt64, w_start DateTime, w_end DateTime) Engine=MergeTree order by tuple();
CREATE WINDOW VIEW test.wv to test.dst AS SELECT count(a) as count, TUMBLE_START(wid) as w_start, TUMBLE_END(wid) as w_end FROM test.mt group by TUMBLE(timestamp, INTERVAL '5' SECOND) as wid;
INSERT INTO test.mt VALUES (1, toDateTime('2020-01-09 12:00:01'));
INSERT INTO test.mt VALUES (2, toDateTime('2020-01-09 12:00:05'));
INSERT INTO test.mt VALUES (3, toDateTime('2020-01-09 12:00:10'));
INSERT INTO test.mt VALUES (4, toDateTime('2020-01-09 12:00:15'));
INSERT INTO test.mt VALUES (5, toDateTime('2020-01-09 12:00:20'));
INSERT INTO test.mt VALUES (6, toDateTime('2020-01-09 12:00:35'));
SELECT sleep(1);
SELECT count, w_start, w_end FROM test.dst order by w_start;
DROP TABLE test.wv;
DROP TABLE test.mt;

View File

@ -0,0 +1,31 @@
0
1 2020-01-09 11:59:57 2020-01-09 12:00:02
1 2020-01-09 11:59:58 2020-01-09 12:00:03
1 2020-01-09 11:59:59 2020-01-09 12:00:04
1 2020-01-09 12:00:00 2020-01-09 12:00:05
1 2020-01-09 12:00:01 2020-01-09 12:00:06
1 2020-01-09 12:00:01 2020-01-09 12:00:06
1 2020-01-09 12:00:02 2020-01-09 12:00:07
1 2020-01-09 12:00:03 2020-01-09 12:00:08
1 2020-01-09 12:00:04 2020-01-09 12:00:09
1 2020-01-09 12:00:05 2020-01-09 12:00:10
1 2020-01-09 12:00:06 2020-01-09 12:00:11
1 2020-01-09 12:00:07 2020-01-09 12:00:12
1 2020-01-09 12:00:08 2020-01-09 12:00:13
1 2020-01-09 12:00:09 2020-01-09 12:00:14
1 2020-01-09 12:00:10 2020-01-09 12:00:15
1 2020-01-09 12:00:11 2020-01-09 12:00:16
1 2020-01-09 12:00:12 2020-01-09 12:00:17
1 2020-01-09 12:00:13 2020-01-09 12:00:18
1 2020-01-09 12:00:14 2020-01-09 12:00:19
1 2020-01-09 12:00:15 2020-01-09 12:00:20
1 2020-01-09 12:00:16 2020-01-09 12:00:21
1 2020-01-09 12:00:17 2020-01-09 12:00:22
1 2020-01-09 12:00:18 2020-01-09 12:00:23
1 2020-01-09 12:00:19 2020-01-09 12:00:24
1 2020-01-09 12:00:20 2020-01-09 12:00:25
1 2020-01-09 12:00:31 2020-01-09 12:00:36
1 2020-01-09 12:00:32 2020-01-09 12:00:37
1 2020-01-09 12:00:33 2020-01-09 12:00:38
1 2020-01-09 12:00:34 2020-01-09 12:00:39
1 2020-01-09 12:00:35 2020-01-09 12:00:40

View File

@ -0,0 +1,23 @@
SET allow_experimental_window_view = 1;
DROP TABLE IF EXISTS test.wv;
DROP TABLE IF EXISTS test.mt;
DROP TABLE IF EXISTS test.dst;
CREATE TABLE test.mt(a Int32, timestamp DateTime) Engine=MergeTree order by tuple();
CREATE TABLE test.dst(count UInt64, w_start DateTime, w_end DateTime) Engine=MergeTree order by tuple();
CREATE WINDOW VIEW test.wv to test.dst AS SELECT count(a) as count, HOP_START(wid) as w_start, HOP_END(wid) as w_end FROM test.mt group by HOP(timestamp, INTERVAL '1' SECOND, INTERVAL '5' SECOND) as wid;
INSERT INTO test.mt VALUES (1, toDateTime('2020-01-09 12:00:01'));
INSERT INTO test.mt VALUES (2, toDateTime('2020-01-09 12:00:05'));
INSERT INTO test.mt VALUES (3, toDateTime('2020-01-09 12:00:10'));
INSERT INTO test.mt VALUES (4, toDateTime('2020-01-09 12:00:15'));
INSERT INTO test.mt VALUES (5, toDateTime('2020-01-09 12:00:20'));
INSERT INTO test.mt VALUES (6, toDateTime('2020-01-09 12:00:35'));
SELECT sleep(1);
SELECT * FROM test.dst order by w_start;
DROP TABLE test.wv;
DROP TABLE test.mt;