Try fix summing.

This commit is contained in:
Nikolai Kochetov 2020-04-03 15:15:08 +03:00
parent 704a94f022
commit 0fe5528842
2 changed files with 25 additions and 18 deletions

View File

@ -168,13 +168,19 @@ void AggregatingSortedTransform::merge()
bool has_previous_group = !last_key.empty(); bool has_previous_group = !last_key.empty();
SortCursor current = queue.current(); SortCursor current = queue.current();
detail::RowRef current_key;
current_key.set(current);
if (!has_previous_group) /// The first key encountered. {
key_differs = true; detail::RowRef current_key;
else current_key.set(current);
key_differs = !last_key.hasEqualSortColumnsWith(current_key);
if (!has_previous_group) /// The first key encountered.
key_differs = true;
else
key_differs = !last_key.hasEqualSortColumnsWith(current_key);
last_key = current_key;
last_chunk_sort_columns.clear();
}
if (key_differs) if (key_differs)
{ {
@ -183,7 +189,6 @@ void AggregatingSortedTransform::merge()
{ {
/// Write the simple aggregation result for the previous group. /// Write the simple aggregation result for the previous group.
insertSimpleAggregationResult(); insertSimpleAggregationResult();
last_key.reset();
return; return;
} }
@ -211,8 +216,6 @@ void AggregatingSortedTransform::merge()
if (!current->isLast()) if (!current->isLast())
{ {
last_key = current_key;
last_chunk_sort_columns.clear();
queue.next(); queue.next();
} }
else else

View File

@ -540,16 +540,22 @@ void SummingSortedTransform::merge()
bool has_previous_group = !last_key.empty(); bool has_previous_group = !last_key.empty();
SortCursor current = queue.current(); SortCursor current = queue.current();
detail::RowRef current_key;
current_key.set(current);
if (!has_previous_group) /// The first key encountered.
{ {
key_differs = true; detail::RowRef current_key;
current_row_is_zero = true; current_key.set(current);
if (!has_previous_group) /// The first key encountered.
{
key_differs = true;
current_row_is_zero = true;
}
else
key_differs = !last_key.hasEqualSortColumnsWith(current_key);
last_key = current_key;
last_chunk_sort_columns.clear();
} }
else
key_differs = !last_key.hasEqualSortColumnsWith(current_key);
if (key_differs) if (key_differs)
{ {
@ -599,8 +605,6 @@ void SummingSortedTransform::merge()
if (!current->isLast()) if (!current->isLast())
{ {
last_key = current_key;
last_chunk_sort_columns.clear();
queue.next(); queue.next();
} }
else else