mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 10:31:57 +00:00
add test
This commit is contained in:
parent
3ecd9f972a
commit
121fd26ab1
@ -0,0 +1,9 @@
|
||||
1 1 1990-01-01 12:00:05
|
||||
1 2 1990-01-01 12:00:05
|
||||
1 3 1990-01-01 12:00:05
|
||||
----ALTER TABLE...MODIFY QUERY----
|
||||
1 1 1990-01-01 12:00:05
|
||||
1 2 1990-01-01 12:00:05
|
||||
1 3 1990-01-01 12:00:05
|
||||
1 12 1990-01-01 12:00:15
|
||||
1 14 1990-01-01 12:00:15
|
47
tests/queries/0_stateless/01076_window_view_alter_query_to.sh
Executable file
47
tests/queries/0_stateless/01076_window_view_alter_query_to.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT --multiquery <<EOF
|
||||
SET allow_experimental_window_view = 1;
|
||||
DROP TABLE IF EXISTS mt;
|
||||
DROP TABLE IF EXISTS dst;
|
||||
DROP TABLE IF EXISTS wv;
|
||||
|
||||
CREATE TABLE dst(count UInt64, market Int64, w_end DateTime) Engine=MergeTree ORDER BY tuple();
|
||||
CREATE TABLE mt(a Int32, market Int64, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple();
|
||||
|
||||
CREATE WINDOW VIEW wv TO dst WATERMARK=ASCENDING AS SELECT count(a) AS count, market, tumbleEnd(wid) AS w_end FROM mt GROUP BY tumble(timestamp, INTERVAL '5' SECOND, 'US/Samoa') AS wid, market;
|
||||
|
||||
INSERT INTO mt VALUES (1, 1, '1990/01/01 12:00:00');
|
||||
INSERT INTO mt VALUES (1, 2, '1990/01/01 12:00:01');
|
||||
INSERT INTO mt VALUES (1, 3, '1990/01/01 12:00:02');
|
||||
INSERT INTO mt VALUES (1, 4, '1990/01/01 12:00:05');
|
||||
INSERT INTO mt VALUES (1, 5, '1990/01/01 12:00:06');
|
||||
EOF
|
||||
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --query="SELECT count(*) FROM dst" | grep -q "3" && break || sleep .5 ||:
|
||||
done
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="SELECT * FROM dst ORDER BY market, w_end;"
|
||||
$CLICKHOUSE_CLIENT --query="SELECT '----ALTER TABLE...MODIFY QUERY----';"
|
||||
|
||||
$CLICKHOUSE_CLIENT --multiquery <<EOF
|
||||
ALTER TABLE wv MODIFY QUERY SELECT count(a) AS count, market * 2, tumbleEnd(wid) AS w_end FROM mt GROUP BY tumble(timestamp, INTERVAL '5' SECOND, 'US/Samoa') AS wid, market;
|
||||
|
||||
INSERT INTO mt VALUES (1, 6, '1990/01/01 12:00:10');
|
||||
INSERT INTO mt VALUES (1, 7, '1990/01/01 12:00:11');
|
||||
INSERT INTO mt VALUES (1, 8, '1990/01/01 12:00:30');
|
||||
EOF
|
||||
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --query="SELECT count(*) FROM dst" | grep -q "5" && break || sleep .5 ||:
|
||||
done
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="SELECT * FROM dst ORDER BY market, w_end;"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE wv"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE mt"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE dst"
|
@ -0,0 +1,9 @@
|
||||
1 1 1990-01-01 12:00:05
|
||||
1 2 1990-01-01 12:00:05
|
||||
1 3 1990-01-01 12:00:05
|
||||
----ALTER TABLE...MODIFY QUERY----
|
||||
1 1 1990-01-01 12:00:05
|
||||
1 2 1990-01-01 12:00:05
|
||||
1 3 1990-01-01 12:00:05
|
||||
1 12 1990-01-01 12:00:15
|
||||
1 14 1990-01-01 12:00:15
|
50
tests/queries/0_stateless/01077_window_view_alter_query_to_modify_source.sh
Executable file
50
tests/queries/0_stateless/01077_window_view_alter_query_to_modify_source.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CURDIR"/../shell_config.sh
|
||||
|
||||
$CLICKHOUSE_CLIENT --multiquery <<EOF
|
||||
SET allow_experimental_window_view = 1;
|
||||
DROP TABLE IF EXISTS mt;
|
||||
DROP TABLE IF EXISTS mt2;
|
||||
DROP TABLE IF EXISTS dst;
|
||||
DROP TABLE IF EXISTS wv;
|
||||
|
||||
CREATE TABLE dst(count UInt64, market Int64, w_end DateTime) Engine=MergeTree ORDER BY tuple();
|
||||
CREATE TABLE mt(a Int32, market Int64, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple();
|
||||
CREATE TABLE mt2(a Int32, market Int64, timestamp DateTime) ENGINE=MergeTree ORDER BY tuple();
|
||||
|
||||
CREATE WINDOW VIEW wv TO dst WATERMARK=ASCENDING AS SELECT count(a) AS count, market, tumbleEnd(wid) AS w_end FROM mt GROUP BY tumble(timestamp, INTERVAL '5' SECOND, 'US/Samoa') AS wid, market;
|
||||
|
||||
INSERT INTO mt VALUES (1, 1, '1990/01/01 12:00:00');
|
||||
INSERT INTO mt VALUES (1, 2, '1990/01/01 12:00:01');
|
||||
INSERT INTO mt VALUES (1, 3, '1990/01/01 12:00:02');
|
||||
INSERT INTO mt VALUES (1, 4, '1990/01/01 12:00:05');
|
||||
INSERT INTO mt VALUES (1, 5, '1990/01/01 12:00:06');
|
||||
EOF
|
||||
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --query="SELECT count(*) FROM dst" | grep -q "3" && break || sleep .5 ||:
|
||||
done
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="SELECT * FROM dst ORDER BY market, w_end;"
|
||||
$CLICKHOUSE_CLIENT --query="SELECT '----ALTER TABLE...MODIFY QUERY----';"
|
||||
|
||||
$CLICKHOUSE_CLIENT --multiquery <<EOF
|
||||
ALTER TABLE wv MODIFY QUERY SELECT count(a) AS count, market * 2, tumbleEnd(wid) AS w_end FROM mt2 GROUP BY tumble(timestamp, INTERVAL '5' SECOND, 'US/Samoa') AS wid, market;
|
||||
|
||||
INSERT INTO mt2 VALUES (1, 6, '1990/01/01 12:00:10');
|
||||
INSERT INTO mt2 VALUES (1, 7, '1990/01/01 12:00:11');
|
||||
INSERT INTO mt2 VALUES (1, 8, '1990/01/01 12:00:30');
|
||||
EOF
|
||||
|
||||
while true; do
|
||||
$CLICKHOUSE_CLIENT --query="SELECT count(*) FROM dst" | grep -q "5" && break || sleep .5 ||:
|
||||
done
|
||||
|
||||
$CLICKHOUSE_CLIENT --query="SELECT * FROM dst ORDER BY market, w_end;"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE wv"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE mt"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE mt2"
|
||||
$CLICKHOUSE_CLIENT --query="DROP TABLE dst"
|
78
tests/queries/0_stateless/01078_window_view_alter_query_watch.py
Executable file
78
tests/queries/0_stateless/01078_window_view_alter_query_watch.py
Executable file
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
# Tags: no-parallel
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
CURDIR = os.path.dirname(os.path.realpath(__file__))
|
||||
sys.path.insert(0, os.path.join(CURDIR, "helpers"))
|
||||
|
||||
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:
|
||||
client1.expect(prompt)
|
||||
client2.expect(prompt)
|
||||
|
||||
client1.send("SET allow_experimental_window_view = 1")
|
||||
client1.expect(prompt)
|
||||
client1.send("SET window_view_heartbeat_interval = 1")
|
||||
client1.expect(prompt)
|
||||
client2.send("SET allow_experimental_window_view = 1")
|
||||
client2.expect(prompt)
|
||||
|
||||
client1.send("CREATE DATABASE IF NOT EXISTS 01078_window_view_alter_query_watch")
|
||||
client1.expect(prompt)
|
||||
client1.send("DROP TABLE IF EXISTS 01078_window_view_alter_query_watch.mt NO DELAY")
|
||||
client1.expect(prompt)
|
||||
client1.send("DROP TABLE IF EXISTS 01078_window_view_alter_query_watch.wv NO DELAY")
|
||||
client1.expect(prompt)
|
||||
|
||||
client1.send(
|
||||
"CREATE TABLE 01078_window_view_alter_query_watch.mt(a Int32, timestamp DateTime('US/Samoa')) ENGINE=MergeTree ORDER BY tuple()"
|
||||
)
|
||||
client1.expect(prompt)
|
||||
client1.send(
|
||||
"CREATE WINDOW VIEW 01078_window_view_alter_query_watch.wv WATERMARK=ASCENDING AS SELECT count(a) AS count, tumbleEnd(wid) AS w_end FROM 01078_window_view_alter_query_watch.mt GROUP BY tumble(timestamp, INTERVAL '5' SECOND, 'US/Samoa') AS wid"
|
||||
)
|
||||
client1.expect(prompt)
|
||||
|
||||
client1.send("WATCH 01078_window_view_alter_query_watch.wv")
|
||||
client1.expect("Query id" + end_of_block)
|
||||
client2.send("INSERT INTO 01078_window_view_alter_query_watch.mt VALUES (1, '1990/01/01 12:00:00');")
|
||||
client2.expect("Ok.")
|
||||
client2.send("INSERT INTO 01078_window_view_alter_query_watch.mt VALUES (1, '1990/01/01 12:00:06');")
|
||||
client2.expect("Ok.")
|
||||
client1.expect("1*" + end_of_block)
|
||||
client1.expect("Progress: 1.00 rows.*\)")
|
||||
client2.send(
|
||||
"ALTER TABLE 01078_window_view_alter_query_watch.wv MODIFY QUERY SELECT count(a) * 2 AS count, tumbleEnd(wid) AS w_end FROM 01078_window_view_alter_query_watch.mt GROUP BY tumble(timestamp, INTERVAL '5' SECOND, 'US/Samoa') AS wid"
|
||||
)
|
||||
client2.expect("Ok.")
|
||||
client1.expect(prompt)
|
||||
client1.send("WATCH 01078_window_view_alter_query_watch.wv")
|
||||
client1.expect("Query id" + end_of_block)
|
||||
client2.send("INSERT INTO 01078_window_view_alter_query_watch.mt VALUES (1, '1990/01/01 12:00:11');")
|
||||
client2.expect("Ok.")
|
||||
client2.send("INSERT INTO 01078_window_view_alter_query_watch.mt VALUES (1, '1990/01/01 12:00:18');")
|
||||
client2.expect("Ok.")
|
||||
client1.expect("2*" + end_of_block)
|
||||
client1.expect("Progress: 1.00 rows.*\)")
|
||||
|
||||
# send Ctrl-C
|
||||
client1.send("\x03", eol="")
|
||||
match = client1.expect("(%s)|([#\$] )" % prompt)
|
||||
if match.groups()[1]:
|
||||
client1.send(client1.command)
|
||||
client1.expect(prompt)
|
||||
client1.send("DROP TABLE 01078_window_view_alter_query_watch.wv NO DELAY;")
|
||||
client1.expect(prompt)
|
||||
client1.send("DROP TABLE 01078_window_view_alter_query_watch.mt;")
|
||||
client1.expect(prompt)
|
||||
client1.send("DROP DATABASE IF EXISTS 01078_window_view_alter_query_watch;")
|
||||
client1.expect(prompt)
|
Loading…
Reference in New Issue
Block a user