haohuaijin opened a new issue, #25995: URL: https://github.com/apache/datafusion/issues/25995
### Is your feature request related to a problem or challenge? Follow-up to #25985. That PR fixes incorrect sign classification in division interval inference. With that fix, integer divisors whose lower or upper endpoint is zero can still produce conservative but unnecessarily wide bounds. Verified with Int64 intervals on PR commit `7707003868eaef7c5da19939d9ca6abbf5919f8c`: | Division | Bounds with #25985 | Tighter bounds for defined quotients | |---|---|---| | `[-3,-1] / [-3,0]` | `[0,+inf)` | `[0,3]` | | `[-6,6] / [-3,0]` | `(-inf,+inf)` | `[-6,6]` | These wide bounds limit filter statistics: for example, they cannot establish that no defined quotient satisfies `a / b > 3` in the first case or `a / b > 6` in the second. ### Describe the solution you'd like Exclude a zero endpoint from integer divisors once in `Interval::div()` before choosing the sign case: - `[-3,0]` becomes `[-3,-1]`. - `[0,3]` becomes `[1,3]`. Integer division by zero has no defined quotient. This normalization would let both division helpers infer tighter bounds without adding separate endpoint cases in each helper. Keep this change limited to integer types and retain conservative handling for singleton `[0,0]` divisors. Preserve the existing handling of divisors that straddle zero, floating-point division, and overflow. Add exact-bound tests for the two examples above, positive zero-ended divisors, signed and unsigned types, and singleton-zero divisors. A local experiment with this normalization produced `[0,3]` and `[-6,6]` for the two examples. ### Describe alternatives you've considered Keep the conservative bounds introduced by #25985. This preserves containment of all defined quotients, but leaves filter statistics less precise. Handling zero endpoints separately in each helper would duplicate the normalization. ### Additional context Suggested during review of #25985: https://github.com/apache/datafusion/pull/25985#discussion_r4172092359 The reviewer agreed this can be handled as a follow-up: https://github.com/apache/datafusion/pull/25985#issuecomment-5968716190 Relevant code: `datafusion/expr-common/src/interval_arithmetic.rs`, especially `Interval::div()` and its division helpers. -- 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]
