ClickHouse/tests/queries/0_stateless/01051_window_view_parser_hop.sql

34 lines
1.8 KiB
MySQL
Raw Normal View History

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;
2021-12-07 08:14:00 +00:00
CREATE WINDOW VIEW wv 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---';
2021-11-22 16:07:13 +00:00
DROP TABLE IF EXISTS wv NO DELAY;
2021-12-07 08:14:00 +00:00
CREATE WINDOW VIEW wv 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---';
2021-11-22 16:07:13 +00:00
DROP TABLE IF EXISTS wv NO DELAY;
2021-12-07 08:14:00 +00:00
CREATE WINDOW VIEW wv 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---';
2021-11-22 16:07:13 +00:00
DROP TABLE IF EXISTS wv NO DELAY;
2021-12-07 08:14:00 +00:00
CREATE WINDOW VIEW wv 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---';
2021-11-22 16:07:13 +00:00
DROP TABLE IF EXISTS wv NO DELAY;
2021-12-07 08:14:00 +00:00
CREATE WINDOW VIEW wv 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---';
2021-11-22 16:07:13 +00:00
DROP TABLE IF EXISTS wv NO DELAY;
2021-12-07 08:14:00 +00:00
CREATE WINDOW VIEW wv 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---';
DROP TABLE IF EXISTS wv NO DELAY;
2021-12-07 08:14:00 +00:00
CREATE WINDOW VIEW wv 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;