This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 8cd18b6cfed [fix](Nereids) should not push down project to the
nullable side of outer join #27912 (#27913)
8cd18b6cfed is described below
commit 8cd18b6cfed0ad3aabedce17ca2f8b94bbd0ba8b
Author: starocean999 <[email protected]>
AuthorDate: Sun Dec 3 14:45:10 2023 +0800
[fix](Nereids) should not push down project to the nullable side of outer
join #27912 (#27913)
---
.../join/PushdownProjectThroughInnerOuterJoin.java | 4 +-
.../PushdownProjectThroughInnerOuterJoinTest.java | 53 ++++++++++++++++++++++
2 files changed, 55 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/PushdownProjectThroughInnerOuterJoin.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/PushdownProjectThroughInnerOuterJoin.java
index 03fd3e8a8d8..cf907e95786 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/PushdownProjectThroughInnerOuterJoin.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/exploration/join/PushdownProjectThroughInnerOuterJoin.java
@@ -136,8 +136,8 @@ public class PushdownProjectThroughInnerOuterJoin
implements ExplorationRuleFact
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;
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/join/PushdownProjectThroughInnerOuterJoinTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/join/PushdownProjectThroughInnerOuterJoinTest.java
index 19be848332d..5e539202d7a 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/join/PushdownProjectThroughInnerOuterJoinTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/exploration/join/PushdownProjectThroughInnerOuterJoinTest.java
@@ -73,6 +73,59 @@ class PushdownProjectThroughInnerOuterJoinTest implements
MemoPatternMatchSuppor
);
}
+ @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
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]