feat(cubesql): Support complex join conditions for grouped joins #9157
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.
Check List
Description of Changes Made (if issue reference is not provided)
Add support for complex join conditions for grouped joins
DataFusion plans non-trivial joins (ones that are not
l.column = r.column) asFilter(CrossJoin(...))To support ungrouped-grouped joins with queries like this SQL API needs to rewrite logical plan like that to
WrappedSelectwith join inside. To do that it need to distinguish between plan coming from regularJOINand actualCROSS JOINwithWHEREon top. This is done with newJoinCheckStage: it starts onFilter(CrossJoin(wrapper, wrapper)), traverses allANDs in filter condition, checks that "leaves" in condition are comparing two join sides, and pulls up that fact. After that regular join rewrite can start on checked condition.Supporting changes:
Allow grouped join sides to have different in_projection flag
Allow non-push_to_cube WrappedSelect in grouped subquery position in join
Make zero members wrapper more expensive than filter member
Replace alias to cube during wrapper pull up
Wrap is_null expressions in parens, to avoid operator precedence issues
Expression like
(foo IS NOT NULL = bar IS NOT NULL)`` would try to comparefoo IS NOT NULLwithbar, not withbar IS NOT NULL`