kosiew opened a new pull request, #15648:
URL: https://github.com/apache/datafusion/pull/15648
## Which issue does this PR close?
- Closes #15636.
## Rationale for this change
This change enhances the performance of logical expressions (`AND` / `OR`)
by introducing lazy evaluation of the right-hand side (RHS) expression only
when necessary. By delaying RHS computation and adding precise short-circuit
logic, we reduce unnecessary computation and improve query
efficiency—especially for large datasets with predictable Boolean patterns.
## What changes are included in this PR?
- Replaced `check_short_circuit` with a new `get_short_circuit_result`
utility that supports both LHS-only and LHS+RHS based short-circuit decisions.
- Delayed RHS evaluation using a closure, evaluating it only when
short-circuiting cannot resolve the result.
- Enhanced short-circuit logic to:
- Consider scalar values (true/false/null)
- Handle arrays with/without nulls accurately
- Expanded test coverage in `test_get_short_circuit_result`:
- Added scalar, array, and null edge cases for both `AND` and `OR`
- Validated behavior with nullable schemas and full-null arrays
## Are these changes tested?
✅ Yes, comprehensive tests were added under `test_get_short_circuit_result`:
- Validates behavior with non-nullable arrays
- Confirms expected logic when nulls are present
- Tests short-circuit outcomes for scalar values
- Covers all combinations of Boolean input edge cases
## Are there any user-facing changes?
No user-facing changes. The optimization is internal to logical expression
evaluation and does not impact public APIs.
--
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]