mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Fix Nullptr dereference in partial merge join with joined_subquery_requires_alias = 0
This commit is contained in:
parent
5fc0e7fc9a
commit
ee4d5d758f
@ -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});
|
||||
|
12
tests/queries/0_stateless/02918_join_pm_lc_crash.reference
Normal file
12
tests/queries/0_stateless/02918_join_pm_lc_crash.reference
Normal file
@ -0,0 +1,12 @@
|
||||
0
|
||||
|
||||
0
|
||||
0
|
||||
|
||||
0
|
||||
0
|
||||
|
||||
\N
|
||||
0
|
||||
|
||||
\N
|
31
tests/queries/0_stateless/02918_join_pm_lc_crash.sql
Normal file
31
tests/queries/0_stateless/02918_join_pm_lc_crash.sql
Normal 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);
|
||||
|
Loading…
Reference in New Issue
Block a user