|
| 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}&async_insert=0&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 --async_insert=0 -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 |
| 48 | + query, |
| 49 | + written_rows, |
| 50 | + ProfileEvents['ReadWriteBufferFromHTTPRequestsSent'] + ProfileEvents['WriteBufferFromHTTPRequestsSent'] as HTTPRequests, |
| 51 | + ProfileEvents['StorageConnectionsCreated'] + ProfileEvents['StorageConnectionsReused'] as HTTPConnections |
| 52 | +from system.query_log |
| 53 | +where |
| 54 | + current_database = currentDatabase() and |
| 55 | + type = 'QueryFinish' and |
| 56 | + query_kind = 'Insert' |
| 57 | +order by ALL |
| 58 | +format Vertical; |
| 59 | +" |
0 commit comments