Description
CH version: 19.4.1.1
Using a cluster with a single node, one distributed table and one non-distributed, and a vstest database:
CREATE TABLE vstest.local_table(id Int32, name String, ts DateTime, oth_id Int32) ENGINE = MergeTree() PARTITION BY toMonday(ts) ORDER BY (ts, id);
CREATE TABLE vstest.dist_table(id Int32, name String, ts DateTime, oth_id Int32) ENGINE = Distributed(vscluster, vstest, local_table);
CREATE TABLE vstest.other_table(id Int32, name String, ts DateTime, trd_id Int32) ENGINE = MergeTree() PARTITION BY toMonday(ts) ORDER BY (ts, id);
INSERT INTO vstest.local_table VALUES(1, 'One', now(), 100);
INSERT INTO vstest.local_table VALUES(2, 'Two', now(), 200);
INSERT INTO vstest.other_table VALUES(100, 'One Hundred', now(), 1000);
INSERT INTO vstest.other_table VALUES(200, 'Two Hundred', now(), 2000);
The "local" join works fine:
select t2.name from dist_table as t1 left join other_table as t2 on t1.oth_id = t2.id
┌─t2.name─────┐
│ One Hundred │
│ Two Hundred │
└─────────────┘
But it is not the case when using the GLOBAL join:
select t2.name from dist_table as t1 GLOBAL left join other_table as t2 on t1.oth_id = t2.id
Getting an error:
Received exception from server (version 19.4.1):
Code: 47. DB::Exception: Received from localhost:19000, ::1. DB::Exception: Unknown identifier: t1.id, context: query: 'SELECT t1.name FROM dist_table AS t1 GLOBAL ALL LEFT JOIN _data1 ON oth_id = t1.id' required_names: 't1.id''t1.name''oth_id' source_tables: 't1'/'dist_table' '_data1' table_aliases: 't1' complex_aliases: masked_columns: array_join_columns: source_columns: 'oth_id' .
Activity
4ertus2 commentedon Apr 2, 2019
We need some time to investigate the issue. As workaround you may try to set alias to the column or try to JOIN with USING instead of ON. It may help.
4ertus2 commentedon Apr 10, 2019
It looks like wrong name qualification. t2.id and t2.name unexpectedly became t1.id and t1.name.
4ertus2 commentedon Apr 10, 2019
As workaround you may change the tables order in query:
[-]"Unknown identifier" error when using GLOBAL join on distributed table[/-][+]Wrong name qualification for the left table in GLOBAL JOIN[/+]dfulachier commentedon Apr 10, 2019
Thank you Artem for studying this bug, and for all your workaround proposals.
None can be systematically applied. By instance, I am not sure the latest is transparent in term of performances (should we not always keep the large table on the left of join, and the small one on the right...?).
This regression is quite annoying, I hope it may be fixed quickly.
4ertus2 commentedon Apr 10, 2019
You are right. It's not possible to save performance with the last workaround.
4ertus2 commentedon Apr 10, 2019
#4969
4ertus2 commentedon Apr 11, 2019
fixed in master