Skip to content

Conversation

@oerling
Copy link
Contributor

@oerling oerling commented Oct 30, 2025

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.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 30, 2025
@meta-codesync
Copy link

meta-codesync bot commented Oct 30, 2025

@oerling has imported this pull request. If you are a Meta employee, you can view this in D85860708.

}
}

TEST_F(PlanTest, outerJoinWithInnerJoin) {
Copy link
Collaborator

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?

Comment on lines +30 to +31
#define AXIOM_ASSERT_PLAN(plan, matcher) \
ASSERT_TRUE(matcher->match(plan)) << plan->toString(true, true);

Copy link
Collaborator

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

Comment on lines 1863 to 2049

// 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);
}

Copy link
Collaborator

@MBkkt MBkkt Oct 31, 2025

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

@oerling oerling force-pushed the pushd-fix-pr branch 5 times, most recently from 8f17090 to c585092 Compare November 9, 2025 01:24
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants