2021-09-12 12:35:27 +00:00
|
|
|
-- Tags: global, no-parallel
|
|
|
|
|
2019-06-14 16:53:16 +00:00
|
|
|
CREATE DATABASE IF NOT EXISTS test_00857;
|
|
|
|
USE test_00857;
|
2019-06-04 12:35:31 +00:00
|
|
|
DROP TABLE IF EXISTS local_table;
|
|
|
|
DROP TABLE IF EXISTS other_table;
|
|
|
|
|
2019-04-10 17:41:19 +00:00
|
|
|
CREATE TABLE local_table
|
|
|
|
(
|
|
|
|
id Int32,
|
|
|
|
name String,
|
|
|
|
ts DateTime,
|
|
|
|
oth_id Int32
|
|
|
|
) ENGINE = MergeTree() PARTITION BY toMonday(ts) ORDER BY (ts, id);
|
|
|
|
|
|
|
|
CREATE TABLE other_table
|
|
|
|
(
|
|
|
|
id Int32,
|
|
|
|
name String,
|
|
|
|
ts DateTime,
|
|
|
|
trd_id Int32
|
|
|
|
) ENGINE = MergeTree() PARTITION BY toMonday(ts) ORDER BY (ts, id);
|
|
|
|
|
|
|
|
INSERT INTO local_table VALUES(1, 'One', now(), 100);
|
|
|
|
INSERT INTO local_table VALUES(2, 'Two', now(), 200);
|
|
|
|
INSERT INTO other_table VALUES(100, 'One Hundred', now(), 1000);
|
|
|
|
INSERT INTO other_table VALUES(200, 'Two Hundred', now(), 2000);
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
select t2.name from remote('127.0.0.2', currentDatabase(), 'local_table') as t1
|
2019-06-14 16:53:16 +00:00
|
|
|
left join test_00857.other_table as t2 -- FIXME: doesn't work properly on remote without explicit database prefix
|
2019-04-10 17:41:19 +00:00
|
|
|
on t1.oth_id = t2.id
|
|
|
|
order by t2.name;
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
select t2.name from other_table as t2
|
|
|
|
global right join remote('127.0.0.2', currentDatabase(), 'local_table') as t1
|
2019-04-10 17:41:19 +00:00
|
|
|
on t1.oth_id = t2.id
|
|
|
|
order by t2.name;
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
select t2.name from remote('127.0.0.2', currentDatabase(), 'local_table') as t1
|
2019-04-10 17:41:19 +00:00
|
|
|
global left join other_table as t2
|
|
|
|
on t1.oth_id = t2.id
|
|
|
|
order by t2.name;
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
select t2.name from remote('127.0.0.2', currentDatabase(), 'local_table') as t1
|
2019-04-10 17:41:19 +00:00
|
|
|
global left join other_table as t2
|
|
|
|
on t1.oth_id = t2.id
|
|
|
|
order by t2.name;
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
select other_table.name from remote('127.0.0.2', currentDatabase(), 'local_table') as t1
|
2019-04-10 17:41:19 +00:00
|
|
|
global left join other_table
|
|
|
|
on t1.oth_id = other_table.id
|
|
|
|
order by other_table.name;
|
|
|
|
|
2019-06-07 15:41:24 +00:00
|
|
|
select other_table.name from remote('127.0.0.2', currentDatabase(), 'local_table') as t1
|
2019-04-10 17:41:19 +00:00
|
|
|
global left join other_table as t2
|
|
|
|
on t1.oth_id = other_table.id
|
|
|
|
order by other_table.name;
|
2019-06-04 12:35:31 +00:00
|
|
|
|
|
|
|
DROP TABLE local_table;
|
|
|
|
DROP TABLE other_table;
|
2019-06-14 16:53:16 +00:00
|
|
|
DROP DATABASE test_00857;
|