mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
any_join_distinct_right_table_keys tests and fix for ORs in JOIN
This commit is contained in:
parent
be034444ba
commit
5ed6b26c9d
@ -1066,7 +1066,7 @@ template <ASTTableJoin::Kind KIND, ASTTableJoin::Strictness STRICTNESS>
|
||||
struct JoinFeatures
|
||||
{
|
||||
static constexpr bool is_any_join = STRICTNESS == ASTTableJoin::Strictness::Any;
|
||||
static constexpr bool is_any_or_old_join = STRICTNESS == ASTTableJoin::Strictness::Any || STRICTNESS == ASTTableJoin::Strictness::RightAny;
|
||||
static constexpr bool is_any_or_semi_join = STRICTNESS == ASTTableJoin::Strictness::Any || STRICTNESS == ASTTableJoin::Strictness::RightAny || (STRICTNESS == ASTTableJoin::Strictness::Semi && KIND == ASTTableJoin::Kind::Left);
|
||||
static constexpr bool is_all_join = STRICTNESS == ASTTableJoin::Strictness::All;
|
||||
static constexpr bool is_asof_join = STRICTNESS == ASTTableJoin::Strictness::Asof;
|
||||
static constexpr bool is_semi_join = STRICTNESS == ASTTableJoin::Strictness::Semi;
|
||||
@ -1344,7 +1344,7 @@ NO_INLINE IColumn::Filter joinRightColumns(
|
||||
used_flags.template setUsed<jf.need_flags, multiple_disjuncts>(find_result);
|
||||
added_columns.appendFromBlock<jf.add_missing>(*mapped.block, mapped.row_num);
|
||||
|
||||
if (jf.is_any_or_old_join)
|
||||
if (jf.is_any_or_semi_join)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -39,3 +39,11 @@ join on OR chain (any right)
|
||||
==
|
||||
2 4
|
||||
6 5
|
||||
any_join_distinct_right_table_keys = 1
|
||||
0 0
|
||||
2 3
|
||||
6 4
|
||||
==
|
||||
2 3
|
||||
5 4
|
||||
100 4
|
||||
|
@ -1,4 +1,6 @@
|
||||
SET joined_subquery_requires_alias = 0;
|
||||
SET any_join_distinct_right_table_keys = 0;
|
||||
|
||||
|
||||
drop table if exists tab1;
|
||||
drop table if exists tab2;
|
||||
@ -48,6 +50,13 @@ select a1, b1, a2, b2 from tab1 any right join tab2 on b1 + 1 = a2 + 1 or a1 + 4
|
||||
select '==';
|
||||
select a2, b2 + 1 from tab1 any right join tab2 on b1 + 1 = a2 + 1 or a1 + 4 = b2 + 2 ORDER BY a2, b2 + 1;
|
||||
|
||||
SET any_join_distinct_right_table_keys = 1;
|
||||
select 'any_join_distinct_right_table_keys = 1';
|
||||
select a2, b2 from tab2 any right join tab3 on a2 = a3 or b2 = b3 ORDER BY a2, b2;
|
||||
select '==';
|
||||
select a3, b3 from tab2 any right join tab3 on a2 = a3 or b2 = b3 ORDER BY a3, b3;
|
||||
|
||||
|
||||
drop table tab1;
|
||||
drop table tab2;
|
||||
drop table tab3;
|
||||
|
12
tests/queries/0_stateless/01660_join_or_inner.reference
Normal file
12
tests/queries/0_stateless/01660_join_or_inner.reference
Normal file
@ -0,0 +1,12 @@
|
||||
any_join_distinct_right_table_keys = 0
|
||||
2 3 2 3
|
||||
6 4 5 4
|
||||
==
|
||||
2 3 2 3
|
||||
6 4 5 4
|
||||
any_join_distinct_right_table_keys = 1
|
||||
2 3 2 3
|
||||
6 4 5 4
|
||||
==
|
||||
2 3 2 3
|
||||
6 4 5 4
|
39
tests/queries/0_stateless/01660_join_or_inner.sql
Normal file
39
tests/queries/0_stateless/01660_join_or_inner.sql
Normal file
@ -0,0 +1,39 @@
|
||||
SET joined_subquery_requires_alias = 0;
|
||||
|
||||
drop table if exists tab1;
|
||||
drop table if exists tab2;
|
||||
drop table if exists tab3;
|
||||
|
||||
create table tab1 (a1 Int32, b1 Int32) engine = MergeTree order by a1;
|
||||
create table tab2 (a2 Int32, b2 Int32) engine = MergeTree order by a2;
|
||||
create table tab3 (a3 Int32, b3 Int32) engine = MergeTree order by a3;
|
||||
|
||||
insert into tab1 values (1, 2);
|
||||
|
||||
insert into tab2 values (2, 3);
|
||||
insert into tab2 values (6, 4);
|
||||
insert into tab2 values (998, 999);
|
||||
|
||||
insert into tab3 values (2, 3);
|
||||
insert into tab3 values (5, 4);
|
||||
insert into tab3 values (100, 4);
|
||||
insert into tab3 values (1998, 1999);
|
||||
|
||||
set max_threads = 1;
|
||||
|
||||
SET any_join_distinct_right_table_keys = 0;
|
||||
select 'any_join_distinct_right_table_keys = 0';
|
||||
select tab2.*, tab3.* from tab2 any join tab3 on a2 = a3 or b2 = b3;
|
||||
select '==';
|
||||
select tab2.*, tab3.* from tab2 any join tab3 on b2 = b3 or a2 = a3;
|
||||
|
||||
SET any_join_distinct_right_table_keys = 1;
|
||||
select 'any_join_distinct_right_table_keys = 1';
|
||||
select tab2.*, tab3.* from tab2 any join tab3 on a2 = a3 or b2 = b3;
|
||||
select '==';
|
||||
select tab2.*, tab3.* from tab2 any join tab3 on b2 = b3 or a2 = a3;
|
||||
|
||||
|
||||
drop table tab1;
|
||||
drop table tab2;
|
||||
drop table tab3;
|
Loading…
Reference in New Issue
Block a user