diff --git a/dbms/include/DB/Storages/MergeTree/MergeTreeBlockInputStream.h b/dbms/include/DB/Storages/MergeTree/MergeTreeBlockInputStream.h index 6cdd8e9b6b9..d7c76819b42 100644 --- a/dbms/include/DB/Storages/MergeTree/MergeTreeBlockInputStream.h +++ b/dbms/include/DB/Storages/MergeTree/MergeTreeBlockInputStream.h @@ -164,7 +164,7 @@ protected: injectRequiredColumns(columns); injectRequiredColumns(pre_columns); - UncompressedCache * uncompressed_cache = use_uncompressed_cache ? storage.context.getUncompressedCache() : NULL; + UncompressedCache * uncompressed_cache = use_uncompressed_cache ? storage.context.getUncompressedCache() : nullptr; reader.reset(new MergeTreeReader(path, owned_data_part, columns, uncompressed_cache, storage, all_mark_ranges)); if (prewhere_actions) pre_reader.reset(new MergeTreeReader(path, owned_data_part, pre_columns, uncompressed_cache, storage, diff --git a/dbms/include/DB/Storages/MergeTree/MergeTreeReader.h b/dbms/include/DB/Storages/MergeTree/MergeTreeReader.h index 1a43cfbcb7b..0896dff40fd 100644 --- a/dbms/include/DB/Storages/MergeTree/MergeTreeReader.h +++ b/dbms/include/DB/Storages/MergeTree/MergeTreeReader.h @@ -168,6 +168,8 @@ public: if (!minimum_size_column) throw std::logic_error{"could not find a column of minimum size in MergeTree"}; + minimum_size_column_name = minimum_size_column->name; + ColumnWithNameAndType column{ minimum_size_column->type->createColumn(), minimum_size_column->type, @@ -242,6 +244,9 @@ public: /// evaluate defaulted columns evaluateMissingDefaults(res, columns, storage.column_defaults, storage.context); + + if (!minimum_size_column_name.empty()) + res.erase(minimum_size_column_name); } catch (const Exception & e) { @@ -369,6 +374,7 @@ private: bool use_uncompressed_cache; MergeTreeData & storage; const MarkRanges & all_mark_ranges; + String minimum_size_column_name; void addStream(const String & name, const IDataType & type, const MarkRanges & all_mark_ranges, size_t level = 0) {