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

   ## Which issue does this PR close?
   
   - Closes https://github.com/apache/datafusion/issues/21320
   
    ### Rationale for this change
   
   When one side of a LEFT/RIGHT/FULL outer join is an EmptyRelation, the 
current PropagateEmptyRelation optimizer rule leaves the join untouched. This 
means the engine still builds a hash table for the empty side, probes every row 
from the non-empty side, finds zero matches, and pads NULLs — all wasted work.
   
   The TODO at lines 76-80 of propagate_empty_relation.rs explicitly called out 
this gap:
   ```
   // TODO: For LeftOut/Full Join, if the right side is empty, the Join can be 
eliminated
   // with a Projection with left side columns + right side columns replaced 
with null values.
   // For RightOut/Full Join, if the left side is empty, the Join can be 
eliminated
   // with a Projection with right side columns + left side columns replaced 
with null values.
   ```
   
    ### What changes are included in this PR?
   
   Extends the PropagateEmptyRelation rule to handle 4 previously unoptimized 
cases by replacing the join with a Projection that null-pads the empty side's 
columns:
   
    ### Are these changes tested?
   
    Yes. 4 new unit tests added:
   
   ###  Are there any user-facing changes?
   
    No API changes.
   


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