mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
fix arrayCumSumNonNegative that it does not accumulative negative values
This commit is contained in:
parent
9dd4a5c727
commit
889d5139ef
@ -55,13 +55,15 @@ struct ArrayCumSumNonNegativeImpl
|
||||
// skip empty arrays
|
||||
if (pos < offsets[i])
|
||||
{
|
||||
accum_sum = data[pos];
|
||||
res_values[pos] = accum_sum > 0 ? accum_sum : 0;
|
||||
accum_sum = data[pos] > 0 ? data[pos] : 0;
|
||||
res_values[pos] = accum_sum;
|
||||
for (++pos; pos < offsets[i]; ++pos)
|
||||
{
|
||||
accum_sum = accum_sum + data[pos];
|
||||
|
||||
res_values[pos] = accum_sum > 0 ? accum_sum : 0;
|
||||
if(accum_sum < 0){
|
||||
accum_sum = 0;
|
||||
}
|
||||
res_values[pos] = accum_sum;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
[1,3,6,10]
|
||||
[1,0,1,0]
|
||||
[1,0,5,3]
|
||||
[0,1,1,1]
|
||||
[0,6,93,-95]
|
||||
[1,0,0,0]
|
||||
[1,0,0,1]
|
||||
[1,1.4,1.2999999999999998]
|
||||
[1,4,5]
|
||||
[0,-4,3,1]
|
||||
|
Loading…
Reference in New Issue
Block a user