bharadwaj-pendyala commented on issue #26222: URL: https://github.com/apache/datafusion/issues/26222#issuecomment-6125040884
I reproduced the NaN half of this at 6663e4348 with a unit test on `SlidingSumAccumulator::<Float64Type>`: add `[1.0, inf]`, slide to `[inf, 2.0]`, then to `[2.0, 3.0]`. The last frame comes back `NaN` instead of `5.0`, because `retract_batch` does `inf - inf`. I can fix the NaN case by keeping the running sum over finite values only. For the float types, I'd count the `NaN`, `+inf` and `-inf` values currently in the frame. `evaluate` would return `NaN` if the frame holds a `NaN` or both infinities, `+inf`/`-inf` if it holds just one sign, and the finite sum otherwise. This would touch the sliding path in `sum.rs` and `AvgAccumulator` in `average.rs`, with sqllogictest cases from the queries above. I'd leave the `1e16` precision case for a separate change. Making retraction exact needs something like the fixed-point accumulator you sketched, or dropping retraction for floats. Both have a perf cost worth discussing on their own. Does tracking non-finite counts make sense for the NaN fix? -- 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]
