ClickHouse/tests/queries/0_stateless/01070_window_view_watch_events.py

71 lines
2.5 KiB
Python
Raw Normal View History

2021-12-13 16:26:01 +00:00
#!/usr/bin/env python3
2021-12-13 15:47:37 +00:00
# Tags: no-parallel
2021-12-12 11:46:40 +00:00
import os
import sys
import signal
CURDIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(CURDIR, "helpers"))
2021-12-12 11:46:40 +00:00
from client import client, prompt, end_of_block
log = None
# uncomment the line below for debugging
# log=sys.stdout
with client(name="client1>", log=log) as client1, client(
name="client2>", log=log
) as client2:
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client2.expect(prompt)
client1.send("SET allow_experimental_window_view = 1")
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client1.send("SET window_view_heartbeat_interval = 1")
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client2.send("SET allow_experimental_window_view = 1")
2021-12-12 11:46:40 +00:00
client2.expect(prompt)
client1.send("CREATE DATABASE IF NOT EXISTS 01070_window_view_watch_events")
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client1.send("DROP TABLE IF EXISTS 01070_window_view_watch_events.mt NO DELAY")
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client1.send("DROP TABLE IF EXISTS 01070_window_view_watch_events.wv NO DELAY")
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client1.send(
"CREATE TABLE 01070_window_view_watch_events.mt(a Int32, timestamp DateTime('US/Samoa')) ENGINE=MergeTree ORDER BY tuple()"
)
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client1.send(
"CREATE WINDOW VIEW 01070_window_view_watch_events.wv WATERMARK=ASCENDING AS SELECT count(a) AS count, tumbleEnd(wid) AS w_end FROM 01070_window_view_watch_events.mt GROUP BY tumble(timestamp, INTERVAL '5' SECOND, 'US/Samoa') AS wid"
)
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client1.send("WATCH 01070_window_view_watch_events.wv EVENTS")
client1.expect("Query id" + end_of_block)
client2.send(
"INSERT INTO 01070_window_view_watch_events.mt VALUES (1, '1990/01/01 12:00:00');"
)
2021-12-12 11:46:40 +00:00
client2.expect("Ok.")
client2.send(
"INSERT INTO 01070_window_view_watch_events.mt VALUES (1, '1990/01/01 12:00:06');"
)
2021-12-12 11:46:40 +00:00
client2.expect("Ok.")
client1.expect("1990-01-01 12:00:05" + end_of_block)
client1.expect("Progress: 1.00 rows.*\)")
2021-12-12 11:46:40 +00:00
# send Ctrl-C
client1.send("\x03", eol="")
match = client1.expect("(%s)|([#\$] )" % prompt)
2021-12-12 11:46:40 +00:00
if match.groups()[1]:
client1.send(client1.command)
client1.expect(prompt)
client1.send("DROP TABLE 01070_window_view_watch_events.wv NO DELAY;")
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client1.send("DROP TABLE 01070_window_view_watch_events.mt;")
2021-12-12 11:46:40 +00:00
client1.expect(prompt)
client1.send("DROP DATABASE IF EXISTS 01070_window_view_watch_events;")
2021-12-12 11:46:40 +00:00
client1.expect(prompt)