Repository navigation
feat: add single flag to hash and nested loop joins for scalar subqueries - #27228
Draft
shehabgamin wants to merge 2 commits into
Draft
shehabgamin wants to merge 2 commits into
shehabgamin wants to merge 2 commits into
Conversation
Contributor
Author
|
"Author has reached the open pull request limit", so this stays in draft for now. That's okay because #27227 has to merge first anyway. |
Contributor
I think this is a bad idea, see |
Contributor
Author
|
@alamb See here #27229 (comment)
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Which issue does this PR close?
RightMark, partitioned null-aware joins #27229.RightMarkand partitioned null-aware joins #27227. It touches the same files, so I'll rebase once that lands.Rationale for this change
In
SELECT o.id, (SELECT i.price FROM items i WHERE i.order_id = o.id) FROM orders oSQL requires at most one item per order and an error otherwise. DataFusion rejects the query at planning time, and a plain join would duplicate the order row.What changes are included in this PR?
singleflag on the logicalJoin,HashJoinExecandNestedLoopJoinExec. The join fails withScalar subquery returned more than one rowwhen an outer row has two matches after all join conditions. A row is emitted only after all its matches are seen.HashJoinExecsupportsLeftandRightsingle joins inCollectLeftandPartitionedmode.NestedLoopJoinExecsupportsRightsingle joins, for correlations without an equality.ScalarSubqueryToJoinplans a non-aggregated correlated scalar subquery as a single join.What is the testing strategy for this PR?
Unit tests for both hash join orientations and modes, the nested loop join, the optimizer rules,
JoinSelectionand proto round trips, plussingle_join.slt.Are there any user-facing changes?
Non-aggregated correlated scalar subqueries now run, and fail only when a row really has two matches. With
enable_physical_uncorrelated_scalar_subquery = false, a multi-row uncorrelated subquery now fails instead of duplicating rows. Code that buildsJoinwith a struct literal must setsingle.