Fix for empty permutation

This commit is contained in:
Alexander Gololobov 2024-11-25 18:30:54 +01:00 committed by GitHub
parent fc61f33bea
commit 12040bbf24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -282,10 +282,12 @@ void checkSortedWithPermutationImpl(size_t rows, Comparator compare, UInt64 limi
if (limit && limit < rows)
rows = limit;
const bool no_permutaiton = permutation.empty();
for (size_t i = 1; i < rows; ++i)
{
const size_t current_row = permutation[i];
const size_t previous_row = permutation[i - 1];
const size_t current_row = no_permutaiton ? i : permutation[i];
const size_t previous_row = no_permutaiton ? (i - 1) : permutation[i - 1];
if (compare(current_row, previous_row))
throw Exception(ErrorCodes::LOGICAL_ERROR,