This commit is contained in:
Alexander Kuzmenkov 2021-02-11 11:39:39 +03:00
parent 467ff74814
commit 363007b964
4 changed files with 44 additions and 19 deletions

View File

@ -1847,26 +1847,36 @@ static bool windowDescriptionComparator(const WindowDescription * _left,
{
return true;
}
if (left[i].column_number < right[i].column_number)
{
return true;
}
if (left[i].direction < right[i].direction)
{
return true;
}
if (left[i].nulls_direction < right[i].nulls_direction)
{
return true;
}
if (left[i] != right[i])
else if (left[i].column_name > right[i].column_name)
{
return false;
}
else if (left[i].column_number < right[i].column_number)
{
return true;
}
else if (left[i].column_number > right[i].column_number)
{
return false;
}
else if (left[i].direction < right[i].direction)
{
return true;
}
else if (left[i].direction > right[i].direction)
{
return false;
}
else if (left[i].nulls_direction < right[i].nulls_direction)
{
return true;
}
else if (left[i].nulls_direction > right[i].nulls_direction)
{
return false;
}
assert(left[i] == right[i]);
}
// Note that we check the length last, because we want to put together the

View File

@ -798,10 +798,10 @@ void WindowTransform::updateAggregationState()
// For now, add the values one by one.
auto * columns = ws.argument_columns.data();
// Removing arena.get() from the loop makes it faster somehow...
auto * _arena = arena.get();
auto * arena_ = arena.get();
for (auto row = first_row; row < past_the_end_row; ++row)
{
a->add(buf, columns, row, _arena);
a->add(buf, columns, row, arena_);
}
}
}

View File

@ -912,3 +912,11 @@ Expression ((Projection + Before ORDER BY))
Expression ((Before window functions + (Projection + Before ORDER BY)))
SettingQuotaAndLimits (Set limits and quota after reading from storage)
ReadFromStorage (SystemNumbers)
-- A test case for the sort comparator found by fuzzer.
SELECT
max(number) OVER (ORDER BY number DESC NULLS FIRST),
max(number) OVER (ORDER BY number ASC NULLS FIRST)
FROM numbers(2)
;
1 0
1 1

View File

@ -308,3 +308,10 @@ from
(select number, intDiv(number, 3) p, mod(number, 5) o
from numbers(16)) t
;
-- A test case for the sort comparator found by fuzzer.
SELECT
max(number) OVER (ORDER BY number DESC NULLS FIRST),
max(number) OVER (ORDER BY number ASC NULLS FIRST)
FROM numbers(2)
;