Repository navigation
fix: preserve outer join equivalences for null rows #26042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Prajwal-k-tech
wants to merge
5
commits into
apache:main
Choose a base branch
from
Prajwal-k-tech:prajwal/26036-outer-join-equivalence
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
11e9fad
fix: preserve outer join equivalences for null rows
Prajwal-k-tech 9449194
fix: support empty schemas in null join batches
Prajwal-k-tech 5f1cabc
fix: preserve equivalence join API compatibility
Prajwal-k-tech 16a78c3
fix: preserve safe outer join equivalences
Prajwal-k-tech 63cc845
test: retain equal non-null outer join expressions
Prajwal-k-tech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2074,6 +2074,55 @@ set datafusion.explain.logical_plan_only = false; | |
| statement ok | ||
| set datafusion.execution.target_partitions = 4; | ||
|
|
||
| statement ok | ||
| set datafusion.execution.target_partitions = 1; | ||
|
|
||
| statement ok | ||
| CREATE TABLE outer_join_sort_left (id BIGINT) AS VALUES (1), (2); | ||
|
|
||
| statement ok | ||
| CREATE TABLE outer_join_sort_right (a BIGINT, b BIGINT) AS VALUES (2, 2), (3, 3); | ||
|
|
||
| query III | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The regression tests cover only LEFT and FULL OUTER JOIN; the new |
||
| SELECT * FROM outer_join_sort_left | ||
| LEFT JOIN ( | ||
| SELECT a, b FROM outer_join_sort_right WHERE b = coalesce(a, 0) | ||
| ) ON id = b | ||
| ORDER BY coalesce(a, 0), id; | ||
| ---- | ||
| 1 NULL NULL | ||
| 2 2 2 | ||
|
|
||
| query III | ||
| SELECT * FROM outer_join_sort_left | ||
| LEFT JOIN ( | ||
| SELECT a, b FROM outer_join_sort_right WHERE b = coalesce(a, 0) | ||
| ) ON id = b | ||
| ORDER BY coalesce(a, 0), id | ||
| LIMIT 1; | ||
| ---- | ||
| 1 NULL NULL | ||
|
|
||
| query III | ||
| SELECT * FROM outer_join_sort_left | ||
| FULL OUTER JOIN ( | ||
| SELECT a, b FROM outer_join_sort_right WHERE b = coalesce(a, 0) | ||
| ) ON id = b | ||
| ORDER BY coalesce(a, 0), id; | ||
| ---- | ||
| 1 NULL NULL | ||
| 2 2 2 | ||
| NULL 3 3 | ||
|
|
||
| statement ok | ||
| DROP TABLE outer_join_sort_left; | ||
|
|
||
| statement ok | ||
| DROP TABLE outer_join_sort_right; | ||
|
|
||
| statement ok | ||
| set datafusion.execution.target_partitions = 4; | ||
|
|
||
| # Planning inner nested loop join | ||
| # inputs are swapped due to inexact statistics + join reordering caused additional projection | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
datafusion/datafusion/physical-expr/src/equivalence/class.rs
Line 816 in 5f1cabc
The public
EquivalenceGroup::join(no schema) keeps the old unsound outer-join behavior with no doc warning or deprecation, so external callers still get wrong equivalences.