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), tumbleStart(wid) AS w_start, tumbleEnd(wid) AS w_end FROM mt GROUP BY tumble(timestamp, INTERVAL '3' 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), tumbleStart(tumble(timestamp, INTERVAL '3' SECOND)) AS w_start, tumbleEnd(wid) AS w_end FROM mt GROUP BY tumble(timestamp, INTERVAL '3' 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), tumbleStart(wid) AS w_start FROM mt GROUP BY tumble(timestamp, INTERVAL '3' 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), tumbleStart(wid) AS w_start, tumbleEnd(wid) AS w_end, date_time FROM mt GROUP BY tumble(timestamp, INTERVAL '3' 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), tumbleStart(wid) AS w_start FROM mt WHERE a != 1 GROUP BY tumble(timestamp, INTERVAL '3' 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), tumbleStart(wid) AS w_start FROM mt WHERE a != 1 GROUP BY tumble(timestamp, INTERVAL '3' 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), tumbleStart(wid) AS w_start, tumbleEnd(tumble(now(), INTERVAL '3' SECOND)) AS w_end FROM mt GROUP BY tumble(now(), INTERVAL '3' SECOND) AS wid;
|