haohuaijin opened a new pull request, #25985:
URL: https://github.com/apache/datafusion/pull/25985

   ## Which issue does this PR close?
   
   No existing issue. The reproduction is described below.
   
   ## Rationale for this change
   
   Division interval inference can report empty filter statistics for a query 
that returns matching rows.
   
   For inputs `(-3, -1), (-2, -1), (0, -2)`, the filter `a / b > 1` returns two 
rows, with quotients 3 and 2. However, interval analysis computes `[-3, 0] / 
[-2, -1]` as `[0, 1]` instead of `[0, 3]`. EXPLAIN consequently reports 
`Rows=Inexact(0)` and exact empty column statistics.
   
   The query results are correct in this reproduction; the bug is in the 
inferred bounds and statistics.
   
   ## What changes are included in this PR?
   
   Compare division operand endpoints against zero when choosing the 
appropriate sign case. Previously, the helpers compared against the lower 
endpoint of the integer zero neighborhood `[-1, 1]`, misclassifying an interval 
ending at zero.
   
   Keep the existing zero-neighborhood checks for intervals that cross zero.
   
   ## What is the testing strategy for this PR?
   
   - Add exact-bound tests for zero-ended numerator intervals divided by 
positive and negative intervals.
   - Check all 784 pairs of integer intervals with endpoints in `[-3, 3]`, 
verifying that every defined runtime quotient is contained in the inferred 
interval.
   - Add a Parquet SQL regression checking both returned rows and EXPLAIN 
statistics.
   
   Validation:
   
   - All 47 interval arithmetic tests passed.
   - `parquet_statistics.slt` passed.
   - `cargo fmt --all`, `git diff --check`, and `cargo clippy --all-targets 
--all-features -- -D warnings` passed.
   - The standard lint suite (`uv run ./dev/rust_lint.sh`) passed.
   - LLVM coverage reports 100% line coverage for the changed production lines; 
all four sign-selection match arms were exercised.
   
   ## Are there any user-facing changes?
   
   Affected filters no longer report false-empty statistics. In the 
reproduction, the row estimate becomes `Inexact(3)`, a conservative estimate 
rather than the exact count of the two matching rows.
   
   Runtime division behavior and public APIs are unchanged.
   


-- 
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]

Reply via email to