edubraqd opened a new pull request, #24895:
URL: https://github.com/apache/datafusion/pull/24895

   ## Which issue does this PR close?
   
   - Closes #24894.
   
   ## Rationale for this change
   
   `DurationAvgAccumulator` accumulated its running sum with plain `+=` / `-`, 
which panics with "attempt to add with overflow" in debug builds (and wraps 
silently in release builds) once the sum of the input durations no longer fits 
in `i64`.
   
   The `sum` aggregate and every other `avg` accumulator deliberately wrap on 
overflow (see the docs on `add_avg_sum`), so this accumulator was the only one 
whose behaviour depended on the build profile.
   
   ## What changes are included in this PR?
   
   Use `wrapping_add` / `wrapping_sub` for the running sum in `update_batch`, 
`merge_batch` and `retract_batch`.
   
   ## Are these changes tested?
   
   Yes. `avg_duration_wraps_on_overflow` feeds two `i64::MAX` durations through 
`update_batch`, `merge_batch` and `retract_batch`; the first two used to panic 
in debug builds.
   
   ## Are there any user-facing changes?
   
   No panic in debug builds. Release builds already wrapped, so results are 
unchanged there.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to