Skip to content

Commit 3268929

Browse files
committed
test that storage URL does not call server on empty data
1 parent deb5bba commit 3268929

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
dst_remote 2 1
2+
dst_remote 4 1
3+
dst_remote 100 1
4+
dst_remote 200 1
5+
dst_remote 300 1
6+
dst_remote 400 1
7+
Row 1:
8+
──────
9+
query: insert into dst_remote format TSV
10+
11+
written_rows: 2
12+
HTTPRequests: 0
13+
HTTPConnections: 0
14+
15+
Row 2:
16+
──────
17+
query: insert into dst_remote format TSV
18+
19+
written_rows: 4
20+
HTTPRequests: 0
21+
HTTPConnections: 0
22+
23+
Row 3:
24+
──────
25+
query: insert into src values
26+
written_rows: 4
27+
HTTPRequests: 0
28+
HTTPConnections: 0
29+
30+
Row 4:
31+
──────
32+
query: insert into src values
33+
written_rows: 6
34+
HTTPRequests: 1
35+
HTTPConnections: 1
36+
37+
Row 5:
38+
──────
39+
query: insert into src values
40+
written_rows: 8
41+
HTTPRequests: 1
42+
HTTPConnections: 1
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env bash
2+
3+
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
4+
# shellcheck source=../shell_config.sh
5+
. "$CURDIR"/../shell_config.sh
6+
7+
set -eu
8+
9+
$CLICKHOUSE_CLIENT -q "
10+
drop table if exists src;
11+
drop table if exists dst_remote;
12+
drop table if exists dst;
13+
drop table if exists mv;
14+
"
15+
16+
$CLICKHOUSE_CLIENT -q "
17+
create table src (key Int, value Int)
18+
engine=MergeTree()
19+
ORDER BY key;
20+
21+
create table dst_remote (key Int, value Int)
22+
engine=MergeTree()
23+
ORDER BY key;
24+
25+
create table dst (key Int, value Int)
26+
engine=URL('${CLICKHOUSE_URL}&query=insert+into+dst_remote+format+TSV', TSV);
27+
28+
create materialized view mv to dst
29+
as select * from src where value > 0;
30+
"
31+
32+
$CLICKHOUSE_CLIENT -q "
33+
insert into src values (1, 0), (2, 1), (3, 0), (4, 1);
34+
35+
insert into src values (10, 0), (20, 0), (30, 0), (40, 0);
36+
37+
insert into src values (100, 1), (200, 1), (300, 1), (400, 1);
38+
"
39+
40+
$CLICKHOUSE_CLIENT -q "
41+
select 'dst_remote', * from dst_remote order by ALL;
42+
"
43+
44+
$CLICKHOUSE_CLIENT -q "
45+
system flush logs query_log;
46+
47+
select query, written_rows, ProfileEvents['ReadWriteBufferFromHTTPRequestsSent'] + ProfileEvents['WriteBufferFromHTTPRequestsSent'] as HTTPRequests, ProfileEvents['StorageConnectionsCreated'] + ProfileEvents['StorageConnectionsReused'] as HTTPConnections
48+
from system.query_log
49+
where
50+
current_database = '${CLICKHOUSE_DATABASE}' and
51+
type = 'QueryFinish' and
52+
query_kind = 'Insert'
53+
order by ALL
54+
format Vertical;
55+
"

0 commit comments

Comments
 (0)