mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
hotfix for duplicates in JOIN ON #4271
This commit is contained in:
parent
dea4f7e817
commit
396d4fb921
@ -469,9 +469,15 @@ bool Join::insertFromBlock(const Block & block)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
NameSet erased; /// HOTFIX: there could be duplicates in JOIN ON section
|
||||||
|
|
||||||
/// Remove the key columns from stored_block, as they are not needed.
|
/// Remove the key columns from stored_block, as they are not needed.
|
||||||
for (const auto & name : key_names_right)
|
for (const auto & name : key_names_right)
|
||||||
stored_block->erase(stored_block->getPositionByName(name));
|
{
|
||||||
|
if (!erased.count(name))
|
||||||
|
stored_block->erase(stored_block->getPositionByName(name));
|
||||||
|
erased.insert(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = stored_block->columns();
|
size_t size = stored_block->columns();
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
1 1 a 1 1 a
|
||||||
|
2 2 b \N \N \N
|
||||||
|
1 1 a 1 1 a
|
||||||
|
2 2 b \N \N \N
|
||||||
|
1 1 a 1 1 a
|
||||||
|
1 1 a 1 1 a
|
||||||
|
2 2 b \N \N \N
|
||||||
|
1 1 a 1 1 a
|
||||||
|
2 2 b \N \N \N
|
19
dbms/tests/queries/0_stateless/00818_join_bug_4271.sql
Normal file
19
dbms/tests/queries/0_stateless/00818_join_bug_4271.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
use test;
|
||||||
|
|
||||||
|
drop table if exists t;
|
||||||
|
drop table if exists s;
|
||||||
|
|
||||||
|
create table t(a Nullable(Int64), b Nullable(Int64), c Nullable(String)) engine = Memory;
|
||||||
|
create table s(a Nullable(Int64), b Nullable(Int64), c Nullable(String)) engine = Memory;
|
||||||
|
|
||||||
|
insert into t values(1,1,'a'), (2,2,'b');
|
||||||
|
insert into s values(1,1,'a');
|
||||||
|
|
||||||
|
select * from t left join s on t.a = s.a;
|
||||||
|
select * from t left join s on t.a = s.a and t.a = s.b;
|
||||||
|
select * from t left join s on t.a = s.a where s.a = 1;
|
||||||
|
select * from t left join s on t.a = s.a and t.a = s.a;
|
||||||
|
select * from t left join s on t.a = s.a and t.b = s.a;
|
||||||
|
|
||||||
|
drop table t;
|
||||||
|
drop table s;
|
Loading…
Reference in New Issue
Block a user