mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 10:31:57 +00:00
Check left join strictness in tryInitDictJoin
This commit is contained in:
parent
6847610ed3
commit
32e8c11cab
@ -339,8 +339,16 @@ static std::optional<String> getDictKeyName(const String & dict_name , ContextPt
|
||||
|
||||
bool TableJoin::tryInitDictJoin(const Block & sample_block, ContextPtr context)
|
||||
{
|
||||
using Strictness = ASTTableJoin::Strictness;
|
||||
|
||||
bool allowed_inner = isInner(kind()) && strictness() == Strictness::All;
|
||||
bool allowed_left = isLeft(kind()) && (strictness() == Strictness::Any ||
|
||||
strictness() == Strictness::All ||
|
||||
strictness() == Strictness::Semi ||
|
||||
strictness() == Strictness::Anti);
|
||||
|
||||
/// Support ALL INNER, [ANY | ALL | SEMI | ANTI] LEFT
|
||||
if (!isLeft(kind()) && !(isInner(kind()) && strictness() == ASTTableJoin::Strictness::All))
|
||||
if (!allowed_inner && !allowed_left)
|
||||
return false;
|
||||
|
||||
const Names & right_keys = keyNamesRight();
|
||||
|
@ -16,6 +16,12 @@ flat: any left
|
||||
2 2 2 2
|
||||
3 3 3 3
|
||||
4 0 0
|
||||
flat: any left + any_join_distinct_right_table_keys
|
||||
0 0 0 0
|
||||
1 1 1 1
|
||||
2 2 2 2
|
||||
3 3 3 3
|
||||
4 0 0
|
||||
flat: semi left
|
||||
0 0 0 0
|
||||
1 1 1 1
|
||||
|
@ -33,6 +33,8 @@ SELECT 'flat: left';
|
||||
SELECT * FROM (SELECT number AS key FROM numbers(5)) s1 LEFT JOIN dict_flat d USING(key) ORDER BY key;
|
||||
SELECT 'flat: any left';
|
||||
SELECT * FROM (SELECT number AS key FROM numbers(5)) s1 ANY LEFT JOIN dict_flat d USING(key) ORDER BY key;
|
||||
SELECT 'flat: any left + any_join_distinct_right_table_keys'; -- falls back to regular join
|
||||
SELECT * FROM (SELECT number AS key FROM numbers(5)) s1 ANY LEFT JOIN dict_flat d USING(key) ORDER BY key SETTINGS any_join_distinct_right_table_keys = '1';
|
||||
SELECT 'flat: semi left';
|
||||
SELECT * FROM (SELECT number AS key FROM numbers(5)) s1 SEMI JOIN dict_flat d USING(key) ORDER BY key;
|
||||
SELECT 'flat: anti left';
|
||||
|
Loading…
Reference in New Issue
Block a user