From 72231facd409b92db41fa68cad2b0b53b1f0cced Mon Sep 17 00:00:00 2001 From: Igor Markelov Date: Mon, 13 May 2024 12:46:01 +0000 Subject: [PATCH] Fix initializing --- src/Interpreters/BestCompressionPermutation.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Interpreters/BestCompressionPermutation.cpp b/src/Interpreters/BestCompressionPermutation.cpp index 893367a51c9..094d1e3d53e 100644 --- a/src/Interpreters/BestCompressionPermutation.cpp +++ b/src/Interpreters/BestCompressionPermutation.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -122,6 +123,16 @@ EqualRanges getEqualRanges(const Block & block, const SortDescription & descript void getBestCompressionPermutation(const Block & block, const SortDescription & description, IColumn::Permutation & permutation) { + if (!block) + return; + if (!permutation.empty() && block.rows() != permutation.size()) + throw Exception(ErrorCodes::LOGICAL_ERROR, "!permutation.empty() && block.rows() != permutation.size()"); + if (permutation.empty()) + { + size_t size = block.rows(); + permutation.resize(size); + iota(permutation.data(), size, IColumn::Permutation::value_type(0)); + } const auto equal_ranges = getEqualRanges(block, description, permutation); const auto not_already_sorted_columns = getNotAlreadySortedColumnsIndex(block, description); for (const auto & range : equal_ranges)