Fix LowCardinality using key for join_use_nulls in pipeline

This commit is contained in:
vdimir 2022-02-15 11:11:59 +00:00
parent 99ca89c0ca
commit 2de6eaf838
No known key found for this signature in database
GPG Key ID: 6EE4CE2BEDC51862
3 changed files with 14 additions and 5 deletions

View File

@ -1524,13 +1524,13 @@ void HashJoin::joinBlockImpl(
continue;
const auto & col = block.getByName(left_name);
bool is_nullable = nullable_right_side || right_key.type->isNullable();
bool is_nullable = JoinCommon::isNullable(right_key.type);
auto right_col_name = getTableJoin().renamedRightColumnName(right_key.name);
ColumnWithTypeAndName right_col(col.column, col.type, right_col_name);
if (right_col.type->lowCardinality() != right_key.type->lowCardinality())
JoinCommon::changeLowCardinalityInplace(right_col);
right_col = correctNullability(std::move(right_col), is_nullable);
block.insert(right_col);
block.insert(std::move(right_col));
}
}
}
@ -1556,7 +1556,7 @@ void HashJoin::joinBlockImpl(
continue;
const auto & col = block.getByName(left_name);
bool is_nullable = nullable_right_side || right_key.type->isNullable();
bool is_nullable = JoinCommon::isNullable(right_key.type);
ColumnPtr thin_column = filterWithBlanks(col.column, filter);
@ -1564,7 +1564,7 @@ void HashJoin::joinBlockImpl(
if (right_col.type->lowCardinality() != right_key.type->lowCardinality())
JoinCommon::changeLowCardinalityInplace(right_col);
right_col = correctNullability(std::move(right_col), is_nullable, null_map_filter);
block.insert(right_col);
block.insert(std::move(right_col));
if constexpr (jf.need_replication)
right_keys_to_replicate.push_back(block.getPositionByName(right_key.name));
@ -2088,7 +2088,7 @@ void HashJoin::reuseJoinedData(const HashJoin & join)
const ColumnWithTypeAndName & HashJoin::rightAsofKeyColumn() const
{
/// It should be nullable if nullable_right_side is true
/// It should be nullable when right side is nullable
return savedBlockSample().getByName(table_join->getOnlyClause().key_names_right.back());
}

View File

@ -115,6 +115,14 @@ bool canBecomeNullable(const DataTypePtr & type)
return can_be_inside;
}
bool isNullable(const DataTypePtr & type)
{
bool is_nullable = type->isNullable();
if (const auto * low_cardinality_type = typeid_cast<const DataTypeLowCardinality *>(type.get()))
is_nullable |= low_cardinality_type->getDictionaryType()->isNullable();
return is_nullable;
}
/// Add nullability to type.
/// Note: LowCardinality(T) transformed to LowCardinality(Nullable(T))
DataTypePtr convertTypeToNullable(const DataTypePtr & type)

View File

@ -59,6 +59,7 @@ private:
};
bool isNullable(const DataTypePtr & type);
bool canBecomeNullable(const DataTypePtr & type);
DataTypePtr convertTypeToNullable(const DataTypePtr & type);
void convertColumnToNullable(ColumnWithTypeAndName & column);