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

   ## Which issue does this PR close?
   
   - Related to #8927.
   
   ## Rationale for this change
   
   `AND`/`OR` only skip the right side for rows the left side already decided 
when few rows are left (`PRE_SELECTION_THRESHOLD`). Otherwise the right side 
runs on the whole batch, so:
   
   - `x = 0 OR 1 / x > 1` and `x != 0 AND 1 / x > 1` can fail with division by 
zero, depending on how many rows match
   - volatile expressions run on rows they shouldn't
   - `OR` doesn't short-circuit at all when the left side has any `NULL`
   
   ## What changes are included in this PR?
   
   - Volatile right side: always evaluated only on the undecided rows
   - Deterministic right side: keeps the current heuristic, but if evaluating 
on the whole batch fails, retry on the undecided rows only
   - `OR` handles `NULL` on the left side per row instead of giving up on the 
whole batch
   
   ## What is the testing strategy for this PR?
   
   - Unit tests in `binary.rs` (`short_circuit` module) for `AND`, `OR`, nested 
`AND`/`OR` and nullable left side, across selectivities on both sides of the 
threshold
   - Updated `select.slt` queries that were expected to fail with division by 
zero
   
   ## Are there any user-facing changes?
   
   Queries like `x = 0 OR 1 / x > 1` no longer fail.
   


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