Fix Nullptr dereference in partial merge join with joined_subquery_requires_alias = 0

This commit is contained in:
vdimir 2023-11-21 12:15:12 +00:00
parent 5fc0e7fc9a
commit ee4d5d758f
No known key found for this signature in database
GPG Key ID: 6EE4CE2BEDC51862
3 changed files with 45 additions and 2 deletions

View File

@ -530,16 +530,16 @@ MergeJoin::MergeJoin(std::shared_ptr<TableJoin> table_join_, const Block & right
addConditionJoinColumn(right_sample_block, JoinTableSide::Right);
JoinCommon::splitAdditionalColumns(key_names_right, right_sample_block, right_table_keys, right_columns_to_add);
const NameSet required_right_keys = table_join->requiredRightKeys();
for (const auto & right_key : key_names_right)
{
if (right_sample_block.getByName(right_key).type->lowCardinality())
if (required_right_keys.contains(right_key) && right_table_keys.getByName(right_key).type->lowCardinality())
lowcard_right_keys.push_back(right_key);
}
JoinCommon::convertToFullColumnsInplace(right_table_keys);
JoinCommon::convertToFullColumnsInplace(right_sample_block, key_names_right);
const NameSet required_right_keys = table_join->requiredRightKeys();
for (const auto & column : right_table_keys)
if (required_right_keys.contains(column.name))
right_columns_to_add.insert(ColumnWithTypeAndName{nullptr, column.type, column.name});

View File

@ -0,0 +1,12 @@
0
0
0
0
0
\N
0
\N

View File

@ -0,0 +1,31 @@
SET joined_subquery_requires_alias = 0, join_algorithm = 'partial_merge';
SET allow_experimental_analyzer = 0, join_use_nulls = 0;
SELECT * FROM (SELECT dummy AS val FROM system.one)
JOIN (SELECT toLowCardinality(toNullable(dummy)) AS val
FROM system.one GROUP BY val WITH TOTALS)
USING (val);
SET allow_experimental_analyzer = 0, join_use_nulls = 1;
SELECT * FROM (SELECT dummy AS val FROM system.one)
JOIN (SELECT toLowCardinality(toNullable(dummy)) AS val
FROM system.one GROUP BY val WITH TOTALS)
USING (val);
SET allow_experimental_analyzer = 1, join_use_nulls = 0;
SELECT * FROM (SELECT dummy AS val FROM system.one)
JOIN (SELECT toLowCardinality(toNullable(dummy)) AS val
FROM system.one GROUP BY val WITH TOTALS)
USING (val);
SET allow_experimental_analyzer = 1, join_use_nulls = 1;
SELECT * FROM (SELECT dummy AS val FROM system.one)
JOIN (SELECT toLowCardinality(toNullable(dummy)) AS val
FROM system.one GROUP BY val WITH TOTALS)
USING (val);