You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Runtime: sum/avg over empty input, avg overflow, and unsupported SQL shapes #659
Found by the DataFusion differential check of #539, executing lowered SQL plans with the #541 runtime and comparing with DataFusion 54.
Wrong results
sum over empty or all-NULL input returns 0, not NULL (e.g. SELECT sum(a) FROM empty_table, or a join group whose values are all NULL). avg returns NaN instead of NULL.
avg of an Int64 column accumulates in a wrapping 64-bit integer: avg over i64::MAX, i64::MIN, -7 gives -2.67.
Differences
64-bit +, -, *, unary minus and i64::MIN % -1 raise an overflow error; DataFusion wraps around (and returns 0 for the modulo).
Not supported by the runtime
Set operations, Concat (grouping sets), subquery scalars, IN lists, LIKE / ILIKE, casts from float or string to integer, upper / round / nullif, filtered aggregates (including count of a nullable column), the count-distinct / stddev / variance / quantile / corr / argMax aggregates, window functions, ORDER BY on a non-projected expression, and the TopK aggregate. About 40% of the 573 checked queries could not run for these reasons.
Possible fix
Return NULL from sum / avg over no non-NULL input; accumulate avg in a float or wide integer; decide whether integer overflow follows DataFusion (wrap) or errors, and document it.
Activity