-
Notifications
You must be signed in to change notification settings - Fork 39
fix: Fix derived table breaks on with joins #573
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
| } | ||
| } | ||
|
|
||
| TEST_F(PlanTest, outerJoinWithInnerJoin) { |
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.
this test pass on current main, is it expected?
| #define AXIOM_ASSERT_PLAN(plan, matcher) \ | ||
| ASSERT_TRUE(matcher->match(plan)) << plan->toString(true, true); | ||
|
|
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.
this macros already defined in this file
|
|
||
| // For example on the right of left outer join, a filter must not go to the enclosing dt but must make its own dt. | ||
| if (!contains(allowedInDt, PlanType::kFilterNode)) { | ||
| return wrapInDt(node); | ||
| } | ||
|
|
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.
There's no test for this.
Even if we allow filter for right part of non-inner join, outerJoinWithInnerJoin test still will pass
8f17090 to
c585092
Compare
ToGraph builds derived tables bottom up. On the returning edge of recursion we add joins or dt postprocessing steps like group by or limit. When there are things that do not fit the implied processing order of a dt, i.e. joins, group by, having, orderby, limit/ofset, we wrap the plan so far in another dt. For example, scan, limit, filter, limit would have (scan, limit) in a dt and the filter and second limit in a dt containing the first one. Now, when a dt as above is to the right of a join, we must start the dt to the right from scratch, meaning that the tables in the dt must be empty and not contain tables from the left side. On the other hand, for a right side that does not introduce a dt break, we must add the tables on the right to the dt where the left side was added. To this effect we set and check allowedInDt correctly also for filters.
c585092 to
9454b48
Compare
ToGraph builds derived tables bottom up. On the returning edge of recursion we add joins or dt postprocessing steps like group by or limit. When there are things that do not fit the implied processing order of a dt, i.e. joins, group by, having, orderby, limit/ofset, we wrap the plan so far in another dt. For example,
scan, limit, filter, limit
would have (scan, limit) in a dt and the filter and second limit in a dt containing the first one. Now, when a dt as above is to the right of a join, we must start the dt to the right from scratch, meaning that the tables in the dt must be empty and not contain tables from the left side. On the other hand, for a right side that does not introduce a dt break, we must add the tables on the right to the dt where the left side was added.
To this effect we set and check allowedInDt correctly also for filters.