apache / apache/datafusion

Complete Possible Join Type Handling for EmptyRelation Propagation Rule

Open
#10,967 13 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
9.3k
Forks
2.4k
Avg merge
3d 7h
Merged PRs (30d)
344

Description

### Is your feature request related to a problem or challenge?

Currently on `main` only the `Inner` join type is considered when doing EmptyRelation propagation, but it's possible to infer if an EmptyRelation is propagatable for some other join types for some other empty conditions.

### Describe the solution you'd like

Fill out the join types per the TODO here, add or remove any that do or do not make sense: https://github.com/apache/datafusion/blob/a8847e1a825f8e588362430d99363672d8c3e7db/datafusion/optimizer/src/propagate_empty_relation.rs#L98-L109

- [x] For LeftOuter/LeftSemi/LeftAnti Join, only the left side is empty, the Join result is empty.
- [x] For LeftSemi Join, if the right side is empty, the Join result is empty.
- [x] For LeftAnti Join, if the right side is empty, the Join result is left side(should exclude null ??).
- [x] For RightOuter/RightSemi/RightAnti Join, only the right side is empty, the Join result is empty.
- [x] For RightSemi Join, if the left side is empty, the Join result is empty.
- [x] For RightAnti Join, if the left side is empty, the Join result is right side(should exclude null ??).
- [x] For Full Join, only both sides are empty, the Join result is empty.
- [ ] 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.

### Describe alternatives you've considered

_No response_

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start in datafusion/optimizer/src/propagate_empty_relation.rs around the TODO referenced in the issue, then trace how join types and empty-side conditions are currently handled. Compare the listed outer, semi, anti, and full join cases, including the unresolved null-replacement cases. Done means the supported cases are implemented consistently and the TODO accurately reflects any cases that remain out of scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.