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---';
|
2021-11-22 16:07:13 +00:00
|
|
|
DROP TABLE IF EXISTS wv NO DELAY;
|
2020-03-11 04:57:04 +00:00
|
|
|
CREATE WINDOW VIEW wv WATERMARK=INTERVAL '1' SECOND AS SELECT count(a), TUMBLE_START(wid) AS w_start, TUMBLE_END(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---';
|
2021-11-22 16:07:13 +00:00
|
|
|
DROP TABLE IF EXISTS wv NO DELAY;
|
2021-12-04 12:30:04 +00:00
|
|
|
CREATE WINDOW VIEW wv AS SELECT count(a), TUMBLE_START(TUMBLE(timestamp, INTERVAL '3' SECOND)) AS w_start, TUMBLE_END(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---';
|
2021-11-22 16:07:13 +00:00
|
|
|
DROP TABLE IF EXISTS wv NO DELAY;
|
2020-03-11 04:57:04 +00:00
|
|
|
CREATE WINDOW VIEW wv AS SELECT count(a), TUMBLE_START(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---';
|
2021-11-22 16:07:13 +00:00
|
|
|
DROP TABLE IF EXISTS wv NO DELAY;
|
2020-03-11 04:57:04 +00:00
|
|
|
CREATE WINDOW VIEW wv AS WITH toDateTime('2018-01-01 00:00:00') AS date_time SELECT count(a), TUMBLE_START(wid) AS w_start, TUMBLE_END(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---';
|
2021-11-22 16:07:13 +00:00
|
|
|
DROP TABLE IF EXISTS wv NO DELAY;
|
2020-03-11 04:57:04 +00:00
|
|
|
CREATE WINDOW VIEW wv AS SELECT count(a), TUMBLE_START(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---';
|
2021-11-22 16:07:13 +00:00
|
|
|
DROP TABLE IF EXISTS wv NO DELAY;
|
2020-03-11 04:57:04 +00:00
|
|
|
CREATE WINDOW VIEW wv AS SELECT count(a), TUMBLE_START(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---';
|
|
|
|
DROP TABLE IF EXISTS wv NO DELAY;
|
|
|
|
CREATE WINDOW VIEW wv AS SELECT count(a), TUMBLE_START(wid) AS w_start, TUMBLE_END(TUMBLE(now(), INTERVAL '3' SECOND)) AS w_end FROM mt GROUP BY TUMBLE(now(), INTERVAL '3' SECOND) AS wid;
|