2023-03-07 11:30:54 +00:00
|
|
|
SET allow_experimental_analyzer = 0;
|
2020-02-12 17:39:57 +00:00
|
|
|
SET allow_experimental_window_view = 1;
|
|
|
|
|
2020-03-11 04:57:04 +00:00
|
|
|
DROP TABLE IF EXISTS mt;
|
2020-02-12 17:39:57 +00:00
|
|
|
|
2020-03-11 04:57:04 +00:00
|
|
|
CREATE TABLE mt(a Int32, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple();
|
2020-02-12 17:39:57 +00:00
|
|
|
|
2020-02-14 08:07:03 +00:00
|
|
|
SELECT '---WATERMARK---';
|
2023-05-03 18:06:46 +00:00
|
|
|
DROP TABLE IF EXISTS wv SYNC;
|
2022-05-14 16:46:49 +00:00
|
|
|
CREATE WINDOW VIEW wv ENGINE Memory WATERMARK=INTERVAL '1' SECOND AS SELECT count(a), hopStart(wid) AS w_start, hopEnd(wid) AS w_end FROM mt GROUP BY hop(timestamp, INTERVAL '3' SECOND, INTERVAL '5' SECOND) AS wid;
|
2020-02-14 08:07:03 +00:00
|
|
|
|
2020-02-12 17:39:57 +00:00
|
|
|
SELECT '---With w_end---';
|
2023-05-03 18:06:46 +00:00
|
|
|
DROP TABLE IF EXISTS wv SYNC;
|
2022-05-14 16:46:49 +00:00
|
|
|
CREATE WINDOW VIEW wv ENGINE Memory AS SELECT count(a), hopStart(wid) AS w_start, hopEnd(wid) AS w_end FROM mt GROUP BY hop(timestamp, INTERVAL '3' SECOND, INTERVAL '5' SECOND) AS wid;
|
2020-02-12 17:39:57 +00:00
|
|
|
|
|
|
|
SELECT '---WithOut w_end---';
|
2023-05-03 18:06:46 +00:00
|
|
|
DROP TABLE IF EXISTS wv SYNC;
|
2022-05-14 16:46:49 +00:00
|
|
|
CREATE WINDOW VIEW wv ENGINE Memory AS SELECT count(a), hopStart(wid) AS w_start FROM mt GROUP BY hop(timestamp, INTERVAL '3' SECOND, INTERVAL '5' SECOND) AS wid;
|
2020-02-12 17:39:57 +00:00
|
|
|
|
|
|
|
SELECT '---WITH---';
|
2023-05-03 18:06:46 +00:00
|
|
|
DROP TABLE IF EXISTS wv SYNC;
|
2022-05-14 16:46:49 +00:00
|
|
|
CREATE WINDOW VIEW wv ENGINE Memory AS WITH toDateTime('2018-01-01 00:00:00') AS date_time SELECT count(a), hopStart(wid) AS w_start, hopEnd(wid) AS w_end, date_time FROM mt GROUP BY hop(timestamp, INTERVAL '3' SECOND, INTERVAL '5' SECOND) AS wid;
|
2020-02-12 17:39:57 +00:00
|
|
|
|
|
|
|
SELECT '---WHERE---';
|
2023-05-03 18:06:46 +00:00
|
|
|
DROP TABLE IF EXISTS wv SYNC;
|
2022-05-14 16:46:49 +00:00
|
|
|
CREATE WINDOW VIEW wv ENGINE Memory AS SELECT count(a), hopStart(wid) AS w_start FROM mt WHERE a != 1 GROUP BY hop(timestamp, INTERVAL '3' SECOND, INTERVAL '5' SECOND) AS wid;
|
2020-02-12 17:39:57 +00:00
|
|
|
|
|
|
|
SELECT '---ORDER_BY---';
|
2023-05-03 18:06:46 +00:00
|
|
|
DROP TABLE IF EXISTS wv SYNC;
|
2022-05-14 16:46:49 +00:00
|
|
|
CREATE WINDOW VIEW wv ENGINE Memory AS SELECT count(a), hopStart(wid) AS w_start FROM mt WHERE a != 1 GROUP BY hop(timestamp, INTERVAL '3' SECOND, INTERVAL '5' SECOND) AS wid ORDER BY w_start;
|
2021-12-04 12:30:04 +00:00
|
|
|
|
|
|
|
SELECT '---With now---';
|
2023-05-03 18:06:46 +00:00
|
|
|
DROP TABLE IF EXISTS wv SYNC;
|
2022-05-14 16:46:49 +00:00
|
|
|
CREATE WINDOW VIEW wv ENGINE Memory AS SELECT count(a), hopStart(wid) AS w_start, hopEnd(hop(now(), INTERVAL '1' SECOND, INTERVAL '3' SECOND)) as w_end FROM mt GROUP BY hop(now(), INTERVAL '1' SECOND, INTERVAL '3' SECOND) AS wid;
|