mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Merge pull request #23437 from rf/rf/deltasum-condition-fix
`deltaSum` aggregate function counter reset bugfix & test
This commit is contained in:
commit
f125db243e
@ -79,7 +79,7 @@ public:
|
|||||||
place_data->sum += rhs_data->sum + (rhs_data->first - place_data->last);
|
place_data->sum += rhs_data->sum + (rhs_data->first - place_data->last);
|
||||||
place_data->last = rhs_data->last;
|
place_data->last = rhs_data->last;
|
||||||
}
|
}
|
||||||
else if ((rhs_data->last < place_data->first && rhs_data->seen_last && place_data->seen_first))
|
else if ((rhs_data->first < place_data->last && rhs_data->seen_last && place_data->seen_first))
|
||||||
{
|
{
|
||||||
// In the opposite scenario, the lhs comes after the rhs, e.g. [4, 6] [1, 2]. Since we
|
// In the opposite scenario, the lhs comes after the rhs, e.g. [4, 6] [1, 2]. Since we
|
||||||
// assume the input interval states are sorted by time, we assume this is a counter
|
// assume the input interval states are sorted by time, we assume this is a counter
|
||||||
@ -87,9 +87,9 @@ public:
|
|||||||
// rhs last value.
|
// rhs last value.
|
||||||
|
|
||||||
place_data->sum += rhs_data->sum;
|
place_data->sum += rhs_data->sum;
|
||||||
place_data->first = rhs_data->first;
|
place_data->last = rhs_data->last;
|
||||||
}
|
}
|
||||||
else if (rhs_data->seen_first)
|
else if (rhs_data->seen_first && !place_data->seen_first)
|
||||||
{
|
{
|
||||||
// If we're here then the lhs is an empty state and the rhs does have some state, so
|
// If we're here then the lhs is an empty state and the rhs does have some state, so
|
||||||
// we'll just take that state.
|
// we'll just take that state.
|
||||||
|
@ -7,3 +7,4 @@
|
|||||||
2
|
2
|
||||||
2.25
|
2.25
|
||||||
6.5
|
6.5
|
||||||
|
7
|
||||||
|
@ -7,3 +7,4 @@ select deltaSumMerge(rows) from (select deltaSumState(arrayJoin([0, 1])) as rows
|
|||||||
select deltaSumMerge(rows) from (select deltaSumState(arrayJoin([4, 5])) as rows union all select deltaSumState(arrayJoin([0, 1])) as rows);
|
select deltaSumMerge(rows) from (select deltaSumState(arrayJoin([4, 5])) as rows union all select deltaSumState(arrayJoin([0, 1])) as rows);
|
||||||
select deltaSum(arrayJoin([2.25, 3, 4.5]));
|
select deltaSum(arrayJoin([2.25, 3, 4.5]));
|
||||||
select deltaSumMerge(rows) from (select deltaSumState(arrayJoin([0.1, 0.3, 0.5])) as rows union all select deltaSumState(arrayJoin([4.1, 5.1, 6.6])) as rows);
|
select deltaSumMerge(rows) from (select deltaSumState(arrayJoin([0.1, 0.3, 0.5])) as rows union all select deltaSumState(arrayJoin([4.1, 5.1, 6.6])) as rows);
|
||||||
|
select deltaSumMerge(rows) from (select deltaSumState(arrayJoin([3, 5])) as rows union all select deltaSumState(arrayJoin([1, 2])) as rows union all select deltaSumState(arrayJoin([4, 6])) as rows);
|
||||||
|
Loading…
Reference in New Issue
Block a user