From 65aceaa668f1bafeedcff072d0eb2f8ab71e1a9a Mon Sep 17 00:00:00 2001 From: Anton Popov Date: Mon, 19 Apr 2021 15:00:31 +0300 Subject: [PATCH] ColumnSparse: fixes --- src/DataTypes/IDataType.cpp | 13 +++++++++++-- src/Interpreters/join_common.cpp | 6 +++++- .../Transforms/AggregatingInOrderTransform.cpp | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/DataTypes/IDataType.cpp b/src/DataTypes/IDataType.cpp index f2aa20514c4..ee995f43bb2 100644 --- a/src/DataTypes/IDataType.cpp +++ b/src/DataTypes/IDataType.cpp @@ -217,8 +217,17 @@ SerializationPtr IDataType::getSerialization(const NameAndTypePair & column, con return subcolumn_type.getSerialization(column.name, callback); }; - auto type_in_storage = column.getTypeInStorage(); - return type_in_storage->getSubcolumnSerialization(column.getSubcolumnName(), base_serialization_getter); + const auto & type_in_storage = column.getTypeInStorage(); + auto subcolumn_serialization = type_in_storage->getSubcolumnSerialization(column.getSubcolumnName(), base_serialization_getter); + + if (type_in_storage->supportsSparseSerialization()) + { + auto sparse_idx_name = escapeForFileName(column.getNameInStorage()) + ".sparse.idx"; + if (callback(sparse_idx_name)) + subcolumn_serialization = std::make_shared(subcolumn_serialization); + + return subcolumn_serialization; + } } return column.type->getSerialization(column.name, callback); diff --git a/src/Interpreters/join_common.cpp b/src/Interpreters/join_common.cpp index e10b9491919..bdb59fa0f15 100644 --- a/src/Interpreters/join_common.cpp +++ b/src/Interpreters/join_common.cpp @@ -52,9 +52,13 @@ namespace JoinCommon void convertColumnToNullable(ColumnWithTypeAndName & column, bool low_card_nullability) { + + if (column.column->isSparse()) + column.column = recursiveRemoveSparse(column.column); + if (low_card_nullability && column.type->lowCardinality()) { - column.column = recursiveRemoveLowCardinality(recursiveRemoveSparse(column.column)); + column.column = recursiveRemoveLowCardinality(column.column); column.type = recursiveRemoveLowCardinality(column.type); } diff --git a/src/Processors/Transforms/AggregatingInOrderTransform.cpp b/src/Processors/Transforms/AggregatingInOrderTransform.cpp index 392e27166ef..24c1ce18924 100644 --- a/src/Processors/Transforms/AggregatingInOrderTransform.cpp +++ b/src/Processors/Transforms/AggregatingInOrderTransform.cpp @@ -230,6 +230,7 @@ IProcessor::Status AggregatingInOrderTransform::prepare() return Status::NeedData; } current_chunk = input.pull(!is_consume_finished); + convertToFullIfSparse(current_chunk); return Status::Ready; }