Skip to content
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 @@ -136,8 +136,8 @@ private Plan pushdownProject(LogicalProject<LogicalJoin<GroupPlan, GroupPlan>> p
return null;
}
// we could not push nullable side project
if ((join.getJoinType().isLeftOuterJoin() && rightContains)
|| (join.getJoinType().isRightOuterJoin() && leftContains)) {
if (((join.getJoinType().isLeftOuterJoin() || join.getJoinType().isFullOuterJoin()) && rightContains)
|| ((join.getJoinType().isRightOuterJoin() || join.getJoinType().isFullOuterJoin()) && leftContains)) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,59 @@ public void pushBothSide() {
);
}

@Test
public void pushRightSide() {
// project (t1.id + 1) as alias, t1.name, (t2.id + 1) as alias, t2.name
List<NamedExpression> projectExprs = ImmutableList.of(
new Alias(new Add(scan1.getOutput().get(0), Literal.of(1)), "alias"),
scan1.getOutput().get(1),
scan2.getOutput().get(1)
);
// complex projection contain ti.id, which isn't in Join Condition
LogicalPlan plan = new LogicalPlanBuilder(scan1)
.join(scan2, JoinType.LEFT_OUTER_JOIN, Pair.of(1, 1))
.projectExprs(projectExprs)
.join(scan3, JoinType.INNER_JOIN, Pair.of(1, 1))
.build();

PlanChecker.from(MemoTestUtils.createConnectContext(), plan)
.applyExploration(PushdownProjectThroughInnerOuterJoin.INSTANCE.buildRules())
.printlnOrigin()
.printlnExploration()
.matchesExploration(
logicalJoin(
logicalProject(
logicalJoin(
logicalProject().when(project -> project.getProjects().size() == 2),
logicalOlapScan()
)
),
logicalOlapScan()
)
);
}

@Test
public void pushNoSide() {
// project (t1.id + 1) as alias, t1.name, (t2.id + 1) as alias, t2.name
List<NamedExpression> projectExprs = ImmutableList.of(
new Alias(new Add(scan1.getOutput().get(0), Literal.of(1)), "alias"),
scan1.getOutput().get(1),
scan2.getOutput().get(1)
);
// complex projection contain ti.id, which isn't in Join Condition
LogicalPlan plan = new LogicalPlanBuilder(scan1)
.join(scan2, JoinType.FULL_OUTER_JOIN, Pair.of(1, 1))
.projectExprs(projectExprs)
.join(scan3, JoinType.INNER_JOIN, Pair.of(1, 1))
.build();

int plansNumber = PlanChecker.from(MemoTestUtils.createConnectContext(), plan)
.applyExploration(PushdownProjectThroughInnerOuterJoin.INSTANCE.buildRules())
.plansNumber();
Assertions.assertEquals(1, plansNumber);
}

@Test
public void pushdownProjectInCondition() {
// project (t1.id + 1) as alias, t1.name, (t2.id + 1) as alias, t2.name
Expand Down