diff --git a/src/Columns/ColumnConst.cpp b/src/Columns/ColumnConst.cpp index 692e4b3c760..080a5086d0a 100644 --- a/src/Columns/ColumnConst.cpp +++ b/src/Columns/ColumnConst.cpp @@ -93,7 +93,7 @@ ColumnPtr ColumnConst::replicate(const Offsets & offsets) const ColumnPtr ColumnConst::permute(const Permutation & perm, size_t limit) const { - limit = getLimitForPermutation(*this, perm, limit); + limit = getLimitForPermutation(size(), perm.size(), limit); return ColumnConst::create(data, limit); } diff --git a/src/Columns/ColumnFunction.cpp b/src/Columns/ColumnFunction.cpp index 6be68c43978..09a3dbad242 100644 --- a/src/Columns/ColumnFunction.cpp +++ b/src/Columns/ColumnFunction.cpp @@ -93,7 +93,7 @@ void ColumnFunction::expand(const Filter & mask, bool inverted) ColumnPtr ColumnFunction::permute(const Permutation & perm, size_t limit) const { - limit = getLimitForPermutation(*this, perm, limit); + limit = getLimitForPermutation(size(), perm.size(), limit); ColumnsWithTypeAndName capture = captured_columns; for (auto & column : capture) diff --git a/src/Columns/ColumnsCommon.h b/src/Columns/ColumnsCommon.h index c3fb946fdaa..c6c2e1ddd45 100644 --- a/src/Columns/ColumnsCommon.h +++ b/src/Columns/ColumnsCommon.h @@ -72,17 +72,16 @@ ColumnPtr selectIndexImpl(const Column & column, const IColumn & indexes, size_t ErrorCodes::LOGICAL_ERROR); } -template -size_t getLimitForPermutation(const Column & column, const IColumn::Permutation & perm, size_t limit) +size_t getLimitForPermutation(size_t column_size, size_t perm_size, size_t limit) { if (limit == 0) - limit = column.size(); + limit = column_size; else - limit = std::min(column.size(), limit); + limit = std::min(column_size, limit); - if (perm.size() < limit) + if (perm_size < limit) throw Exception(ErrorCodes::SIZES_OF_COLUMNS_DOESNT_MATCH, - "Size of permutation ({}) is less than required ({})", perm.size(), limit); + "Size of permutation ({}) is less than required ({})", perm_size, limit); return limit; } @@ -90,7 +89,7 @@ size_t getLimitForPermutation(const Column & column, const IColumn::Permutation template ColumnPtr permuteImpl(const Column & column, const IColumn::Permutation & perm, size_t limit) { - limit = getLimitForPermutation(column, perm, limit); + limit = getLimitForPermutation(column.size(), perm.size(), limit); return column.indexImpl(perm, limit); }