-
Couldn't load subscription status.
- Fork 135
fix(core): disable EliminateCrossJoin rule #1354
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughEliminateCrossJoin was removed from the unparsing optimization rule set (commented/disabled) to avoid generating invalid SQL; a unit test was added to assert CROSS JOINs remain explicit and projected columns appear from both tables. Changes
Sequence Diagram(s)(Skipped — change is a rule toggle and an added test; no control-flow or new runtime interactions to visualize.) Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
wren-core/core/src/mdl/context.rs (1)
250-251: Appropriate fix to prevent invalid SQL generation.Disabling the
EliminateCrossJoinrule correctly addresses the issue described in the PR where the optimizer was generating invalid SQL with unnamed subqueries containing references to base-table aliases that were out of scope.The comment clearly documents the rationale. However, since the comment mentions "expression should be rebased manually," consider adding a TODO comment or issue reference to track future work on implementing proper expression rebasing to re-enable this optimization safely.
Consider adding a reference to track future work:
- // Disable EliminateCrossJoin to avoid generate invalid sql (expression should be rebased manually) + // Disable EliminateCrossJoin to avoid generate invalid sql (expression should be rebased manually) + // TODO: Implement expression rebasing to safely re-enable this optimization // Arc::new(EliminateCrossJoin::new()),
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
wren-core/core/src/mdl/context.rs(1 hunks)wren-core/core/src/mdl/mod.rs(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
wren-core/core/src/mdl/mod.rs (1)
wren-core-base/src/mdl/builder.rs (5)
new(46-58)new(105-119)new(190-205)new(289-298)new(325-337)
🔇 Additional comments (1)
wren-core/core/src/mdl/mod.rs (1)
3777-3812: LGTM! Test correctly validates cross-join preservation.The test appropriately verifies that when the
EliminateCrossJoinrule is disabled, cross joins are preserved in the transformed SQL output. The expected snapshot confirms that:
- The comma-separated table syntax is converted to an explicit
CROSS JOIN- The join condition remains in the
WHEREclause rather than being converted to anINNER JOIN ONclause- The resulting SQL structure is valid
EliminateCrossJoinrule will replace the cross-join plan with the filter to the inner-join plan if possible. However, the generated plan can't be handled by the unparser correctly.Consider the following SQL:
If the number of the joined tables is greater than 2, they will be converted to an inner join chain
The unparsed result will be
It's not a valid SQL for most databases because the base table of the select item is placed in an unnamed subquery. We need to rebase the expression manually.
Summary by CodeRabbit
Bug Fixes
Tests