Commit 05871c3
authored
aggregate_fn: Return NaN instead of null for mean of all-null input (#8365)
`Mean::finalize_scalar` returned null when the count was zero, while the
array `finalize` path computes `sum/count = 0/0 = NaN` for the same
input. A mean over an all-null group therefore gave different results
depending on which accumulator we're using.
https://github.com/vortex-data/vortex/blob/90d743356722a8d5ca7e39053229654778bacf46/vortex-array/src/aggregate_fn/fns/mean/mod.rs#L85-L93
Since nulls are skipped during accumulation (as in standard SQL
aggregation), an all-null input is an empty mean. Both paths now let the
division produce NaN.
Note this only matters for the count = 0 case: sum overflow still
returns null.
Signed-off-by: Dimitar Dimitrov <dimitar@spiraldb.com>1 parent 9383c35 commit 05871c3
1 file changed
Lines changed: 5 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
| |||
230 | 232 | | |
231 | 233 | | |
232 | 234 | | |
233 | | - | |
| 235 | + | |
234 | 236 | | |
235 | 237 | | |
236 | 238 | | |
237 | | - | |
| 239 | + | |
238 | 240 | | |
239 | 241 | | |
240 | 242 | | |
| |||
0 commit comments