2021-06-03 18:07:19 +00:00
#!/usr/bin/env bash
2021-09-12 12:35:27 +00:00
# Tags: distributed
2021-06-03 18:07:19 +00:00
# FIXME: this is an .sh test because JOIN with Distributed in the left will use default database for the right.
CUR_DIR = $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd )
# shellcheck source=../shell_config.sh
. " $CUR_DIR " /../shell_config.sh
$CLICKHOUSE_CLIENT -nm -q "
drop table if exists test_distributed;
drop table if exists test_source;
drop table if exists test_shard;
drop table if exists test_local;
create table test_shard ( k UInt64, v UInt64) ENGINE Memory( ) ;
create table test_local ( k UInt64, v UInt64) ENGINE Memory( ) ;
create table test_source ( k UInt64, v UInt64) ENGINE Memory( ) ;
insert into test_shard values ( 1, 1) ;
insert into test_local values ( 1, 2) ;
2024-02-28 00:00:17 +00:00
create materialized view $CLICKHOUSE_DATABASE .test_distributed engine Distributed( 'test_cluster_two_shards' , $CLICKHOUSE_DATABASE , 'test_shard' , k) as select k, v from test_source;
2021-06-03 18:07:19 +00:00
select * from test_distributed td asof join $CLICKHOUSE_DATABASE .test_local tl on td.k = tl.k and td.v < tl.v;
2023-10-17 14:02:30 +00:00
select td.v, td.k, td.v, tl.v, tl.k, td.v from test_distributed td asof join $CLICKHOUSE_DATABASE .test_local tl on td.k = tl.k and td.v < tl.v FORMAT TSVWithNamesAndTypes;
2021-06-03 18:07:19 +00:00
select * from test_distributed td asof join $CLICKHOUSE_DATABASE .test_local tl on td.k = tl.k and td.v < tl.v order by td.v;
select * from test_distributed td asof join $CLICKHOUSE_DATABASE .test_local tl on td.k = tl.k and td.v < tl.v order by tl.v;
select sum( td.v) from test_distributed td asof join $CLICKHOUSE_DATABASE .test_local tl on td.k = tl.k and td.v < tl.v group by tl.k;
select sum( tl.v) from test_distributed td asof join $CLICKHOUSE_DATABASE .test_local tl on td.k = tl.k and td.v < tl.v group by td.k;
2023-06-01 10:52:05 +00:00
select td.k, tl.* from test_distributed td join $CLICKHOUSE_DATABASE .test_local tl on td.k = tl.k;
2021-06-03 18:07:19 +00:00
drop table test_distributed;
drop table test_source;
drop table test_shard;
drop table test_local;
"