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

   ## Which issue does this PR close?
   
   - Closes #26632.
   
   ## Rationale for this change
   
   `ProjectionPushdown` moves single-side parts of a nested loop join filter 
into a projection below the join, including `CASE` branches and the right side 
of `OR` and `AND`. That projection runs them on every row, so a guarded cast 
like `CASE WHEN r.v > 100 THEN CAST(l.s AS INT) ELSE 0 END > 1` fails even when 
the `WHEN` is false for every row.
   
   ## What changes are included in this PR?
   
   `JoinFilterRewriter::rewrite` now only looks for pushdown candidates in 
children that are always evaluated, the same rule as `conditional_children` in 
`CommonSubexprEliminate`: the base expression and first `WHEN` of a `CASE`, and 
the left operand of `AND` and `OR`. Arguments of a function that 
`short_circuits()` are all treated as conditional. The rest stays in the join 
filter.
   
   Top-level conjuncts are still searched in full. `PushDownFilter` already 
splits and reorders them, so their order guarantees nothing, and treating them 
as conditional would lose the pushdown in the common `cheap AND expensive` case.
   
   ## What is the testing strategy for this PR?
   
   `nested_loop_join_conditional.slt` runs each shape from the issue and 
compares with the same filter over the cross join, and three `EXPLAIN`s check 
what is still pushed down. It fails on `main`.
   
   `does_not_push_down_short_circuiting_expressions` asserted that both sides 
of `false AND ...` are pushed down, which this PR keeps, so I renamed it 
`pushes_down_all_top_level_conjuncts` and gave the old name to a `false OR ...` 
case.
   
   ## Are there any user-facing changes?
   
   No API changes. Plans only change where part of the filter is evaluated 
conditionally; no existing plan in the tests changes.
   
   Drafted with Claude. I reviewed it and reran the issue's queries with a 
`datafusion-cli` built from this branch.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


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