s5dsn-eqee opened a new issue, #27183:
URL: https://github.com/apache/datafusion/issues/27183
### Describe the bug
`array_sum` casts every element to `Float64` and returns `Float64`, so sums
of
integer or decimal arrays are rounded once they pass 2^53. The `sum`
aggregate
over the same values is exact.
### To Reproduce
```sql
SELECT array_sum([9007199254740993, 1]);
-- 9007199254740992 (Float64)
SELECT sum(v) FROM (VALUES (9007199254740993), (1)) AS t(v);
-- 9007199254740994 (Int64)
Casting the input to List(Decimal128(38, 0)) first doesn't help: the result
is still Float64.
### Expected behavior
array_sum follows the sum aggregate's types: Int64 for signed integers,
UInt64 for unsigned, a widened decimal for decimals, Float64 for floats.
Integer overflow wraps, as sum does.
### Additional context
Found while mapping narwhals' list.sum onto DataFusion 55. That backend now
refuses integer lists because the result can be silently wrong.
### Willingness to contribute
None
--
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]