Correct sample_block in HashJoin for dict join with join_algorithm = auto

This commit is contained in:
vdimir 2021-04-19 18:02:56 +03:00
parent 14800f0c52
commit a95c4dcfff
No known key found for this signature in database
GPG Key ID: F57B3E10A21DBB31
3 changed files with 12 additions and 1 deletions

View File

@ -571,7 +571,7 @@ namespace
void HashJoin::initRightBlockStructure(Block & saved_block_sample)
{
/// We could remove key columns for LEFT | INNER HashJoin but we should keep them for JoinSwitcher (if any).
bool save_key_columns = !table_join->forceHashJoin() || isRightOrFull(kind);
bool save_key_columns = !(table_join->forceHashJoin() || table_join->dictionary_reader) || isRightOrFull(kind);
if (save_key_columns)
{
saved_block_sample = right_table_keys.cloneEmpty();

View File

@ -101,3 +101,9 @@ not optimized (smoke)
-
2 2 2 2
3 3 3 3
issue 23002
0 0 0 0 0
1 1 1 1 1
2 2 2 2 2
3 3 3 3 3
4 0 0 0

View File

@ -82,6 +82,11 @@ SELECT * FROM (SELECT number AS key FROM numbers(2)) s1 SEMI RIGHT JOIN dict_fla
SELECT '-';
SELECT * FROM (SELECT number AS key FROM numbers(2)) s1 ANTI RIGHT JOIN dict_flat d USING(key) ORDER BY s1.key;
SET join_use_nulls = 0;
SET join_algorithm = 'auto';
SELECT 'issue 23002';
SELECT * FROM (SELECT number AS key FROM numbers(5)) s1 LEFT JOIN dict_flat d ON s1.key = d.key ORDER BY s1.key;
DROP DICTIONARY dict_flat;
DROP DICTIONARY dict_hashed;
DROP DICTIONARY dict_complex_cache;