tokoko opened a new pull request, #58506:
URL: https://github.com/apache/spark/pull/58506

   ### What changes were proposed in this pull request?
   `PropagateEmptyRelation` already rewrites a join whose condition is 
`FalseLiteral` for most join types: inner/cross and left semi collapse to an 
empty relation for example. This PR adds `FullOuter` handling. With a false 
condition no row on either side can find a match, so the join is equivalent to 
a UNION ALL of both sides, each padded with nulls for the other side's columns.
   
   ### Why are the changes needed?
   1 = 0 is not an equi-join condition, so today this plan runs as a 
BroadcastNestedLoopJoin which is inefficient. After the rewrite both sides are 
scanned once and fuse into a single whole-stage codegen stage, with no exchange.
   
   Users can usually write the union themselves, but not always. The motivating 
case is a MERGE with an intentionally non-matching condition, where the join is 
generated by the MERGE rewrite rather than written by hand:
   ```
   MERGE INTO target_table AS t
   USING source AS s ON 1 = 0
   WHEN NOT MATCHED THEN INSERT *
   WHEN NOT MATCHED BY SOURCE AND [replaceWhereCondition] THEN DELETE
   ```
   
   This is the shape for a replaceWhere-style operation made possible by #52185.
   
   ### Does this PR introduce _any_ user-facing change?
   No. Query results are unchanged; only the optimized plan changes.
   
   ### How was this patch tested?
   New and updated unit tests.
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   Generated-by: Claude Code 2.1.259 (Claude Opus 5)


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