Skip to content
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

[fix](Nereids) join order is not right after sql parsing #28721

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,7 @@ private LogicalPlan withRelations(LogicalPlan inputPlan, List<RelationContext> r
LogicalPlan left = inputPlan;
for (RelationContext relation : relations) {
// build left deep join tree
LogicalPlan right = visitRelation(relation);
LogicalPlan right = withJoinRelations(visitRelation(relation), relation);
left = (left == null) ? right :
new LogicalJoin<>(
JoinType.CROSS_JOIN,
Expand All @@ -2818,7 +2818,6 @@ private LogicalPlan withRelations(LogicalPlan inputPlan, List<RelationContext> r
Optional.empty(),
left,
right);
left = withJoinRelations(left, relation);
// TODO: pivot and lateral view
}
return left;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected void runBeforeAll() throws Exception {
public void testFromClauseDelete() throws AnalysisException {
String sql = "delete from t1 a using src join t2 on src.k1 = t2.k1 where t2.k1 = a.k1";
LogicalPlan parsed = new NereidsParser().parseSingle(sql);
Assertions.assertTrue(parsed instanceof DeleteFromUsingCommand);
Assertions.assertInstanceOf(DeleteFromUsingCommand.class, parsed);
DeleteFromUsingCommand command = ((DeleteFromUsingCommand) parsed);
LogicalPlan plan = command.completeQueryPlan(connectContext, command.getLogicalQuery());
PlanChecker.from(connectContext, plan)
Expand All @@ -83,19 +83,22 @@ public void testFromClauseDelete() throws AnalysisException {
logicalOlapTableSink(
logicalProject(
logicalJoin(
logicalJoin(
logicalProject(
logicalFilter(
logicalOlapScan()
logicalProject(
logicalJoin(
logicalProject(
logicalFilter(
logicalOlapScan()
)
),
logicalProject(
logicalFilter(
logicalOlapScan()
)
)
),
logicalProject(
logicalOlapScan())
)
),
logicalProject(
logicalFilter(
logicalOlapScan()
)
logicalOlapScan()
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,18 @@ public void testFromClauseUpdate() {
LogicalPlan plan = command.completeQueryPlan(connectContext, command.getLogicalQuery());
PlanChecker.from(connectContext, plan)
.analyze(plan)
.rewrite()
.matches(
logicalOlapTableSink(
logicalProject(
logicalFilter(
logicalJoin(
logicalSubQueryAlias(
logicalFilter(
logicalOlapScan()
)
),
logicalJoin(
logicalJoin(
logicalProject(
logicalFilter(
logicalOlapScan()
)
),
logicalProject(
logicalOlapScan())
),
logicalProject(
logicalFilter(
logicalOlapScan()
)
logicalOlapScan(),
logicalFilter(
logicalOlapScan()
)
)
)
Expand Down
Loading
Loading