mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Cast columns to sample structure for StirageJoin::read
This commit is contained in:
parent
d6dd133bee
commit
89ee8aefd9
@ -10,6 +10,7 @@
|
||||
#include <DataTypes/NestedUtils.h>
|
||||
#include <Interpreters/joinDispatch.h>
|
||||
#include <Interpreters/TableJoin.h>
|
||||
#include <Interpreters/castColumn.h>
|
||||
#include <Common/assert_cast.h>
|
||||
#include <Common/quoteString.h>
|
||||
|
||||
@ -321,7 +322,7 @@ private:
|
||||
template <ASTTableJoin::Kind KIND, ASTTableJoin::Strictness STRICTNESS, typename Maps>
|
||||
Chunk createChunk(const Maps & maps)
|
||||
{
|
||||
MutableColumns columns = restored_block.cloneEmpty().mutateColumns();
|
||||
MutableColumns mut_columns = restored_block.cloneEmpty().mutateColumns();
|
||||
|
||||
size_t rows_added = 0;
|
||||
|
||||
@ -329,7 +330,7 @@ private:
|
||||
{
|
||||
#define M(TYPE) \
|
||||
case HashJoin::Type::TYPE: \
|
||||
rows_added = fillColumns<KIND, STRICTNESS>(*maps.TYPE, columns); \
|
||||
rows_added = fillColumns<KIND, STRICTNESS>(*maps.TYPE, mut_columns); \
|
||||
break;
|
||||
APPLY_FOR_JOIN_VARIANTS_LIMITED(M)
|
||||
#undef M
|
||||
@ -342,19 +343,23 @@ private:
|
||||
if (!rows_added)
|
||||
return {};
|
||||
|
||||
/// Correct nullability
|
||||
Columns columns;
|
||||
columns.reserve(mut_columns.size());
|
||||
for (auto & col : mut_columns)
|
||||
columns.emplace_back(std::move(col));
|
||||
|
||||
/// Correct nullability and LowCardinality types
|
||||
for (size_t i = 0; i < columns.size(); ++i)
|
||||
{
|
||||
bool src_nullable = restored_block.getByPosition(i).type->isNullable();
|
||||
bool dst_nullable = sample_block.getByPosition(i).type->isNullable();
|
||||
const auto & src = restored_block.getByPosition(i);
|
||||
const auto & dst = sample_block.getByPosition(i);
|
||||
|
||||
if (src_nullable && !dst_nullable)
|
||||
if (!src.type->equals(*dst.type))
|
||||
{
|
||||
auto & nullable_column = assert_cast<ColumnNullable &>(*columns[i]);
|
||||
columns[i] = nullable_column.getNestedColumnPtr()->assumeMutable();
|
||||
auto arg = src;
|
||||
arg.column = std::move(columns[i]);
|
||||
columns[i] = castColumn(arg, dst.type);
|
||||
}
|
||||
else if (!src_nullable && dst_nullable)
|
||||
columns[i] = makeNullable(std::move(columns[i]))->assumeMutable();
|
||||
}
|
||||
|
||||
UInt64 num_rows = columns.at(0)->size();
|
||||
|
Loading…
Reference in New Issue
Block a user