EeshanBembi opened a new pull request, #17554:
URL: https://github.com/apache/datafusion/pull/17554
## Summary
Add SQL-compliant overflow checking for arithmetic operations by default.
Previously,
DataFusion allowed numeric overflow to wrap silently, which differs from
SQL standard
behavior and other databases like PostgreSQL, Trino, and Snowflake.
## Changes
- Add `fail_on_overflow` configuration option that defaults to `true` for
SQL-standard
behavior
- Update `BinaryExpr` to use checked arithmetic operations when overflow
checking is enabled
- Modify `binary()` function signature to accept `ExecutionProps` for
configuration access
- Fix all call sites throughout the codebase to pass the `ExecutionProps`
parameter
- Add helper functions for test code to provide default `ExecutionProps`
## Behavior
**Before:**
```sql
SELECT 10000000000 * 10000000000;
-- Returns: 7766279631452241920 (wrapped overflow)
After (default):
SELECT 10000000000 * 10000000000;
-- Error: Arithmetic overflow: Overflow happened on: 10000000000 *
10000000000
After (with overflow disabled):
SET datafusion.execution.fail_on_overflow = false;
SELECT 10000000000 * 10000000000;
-- Returns: 7766279631452241920 (wrapped overflow)
```
Testing
- All existing overflow tests pass
- New behavior verified with the example from the issue
- Configuration option properly toggles behavior
- Maintains backward compatibility through configuration
Fixes #17539
--
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]