This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 84bb42fea09 [fix](Nereids) should not infer not null from mark join
(#30897)
84bb42fea09 is described below
commit 84bb42fea09050884cdd52ee1fb4ec386b3caebd
Author: morrySnow <[email protected]>
AuthorDate: Tue Feb 6 16:55:10 2024 +0800
[fix](Nereids) should not infer not null from mark join (#30897)
---
.../doris/nereids/rules/rewrite/InferJoinNotNull.java | 1 +
.../doris/nereids/rules/rewrite/InferJoinNotNullTest.java | 12 ++++++++++++
.../org/apache/doris/nereids/util/LogicalPlanBuilder.java | 13 +++++++++++++
3 files changed, 26 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferJoinNotNull.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferJoinNotNull.java
index d583512145f..e7168ca0e99 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferJoinNotNull.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/InferJoinNotNull.java
@@ -43,6 +43,7 @@ public class InferJoinNotNull extends OneRewriteRuleFactory {
// TODO: maybe consider ANTI?
return logicalJoin(any(), any())
.when(join -> join.getJoinType().isInnerJoin() ||
join.getJoinType().isSemiJoin())
+ .whenNot(LogicalJoin::isMarkJoin)
.thenApply(ctx -> {
LogicalJoin<Plan, Plan> join = ctx.root;
Set<Expression> conjuncts = new HashSet<>();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/InferJoinNotNullTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/InferJoinNotNullTest.java
index 867c2000c37..a8ac045d807 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/InferJoinNotNullTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/rewrite/InferJoinNotNullTest.java
@@ -70,6 +70,18 @@ class InferJoinNotNullTest implements
MemoPatternMatchSupported {
logicalFilter().when(f ->
f.getPredicate().toString().equals("( not id#2 IS NULL)"))
)
);
+
+ LogicalPlan rightMarkSemiJoin = new LogicalPlanBuilder(scan1)
+ .markJoin(scan2, JoinType.RIGHT_SEMI_JOIN, Pair.of(0, 0))
+ .build();
+ PlanChecker.from(MemoTestUtils.createConnectContext(),
rightMarkSemiJoin)
+ .applyTopDown(new InferJoinNotNull())
+ .matches(
+ rightSemiLogicalJoin(
+ logicalOlapScan(),
+ logicalOlapScan()
+ )
+ );
}
@Test
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/LogicalPlanBuilder.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/LogicalPlanBuilder.java
index 971ccd90ef5..697a830279f 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/nereids/util/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/nereids/util/LogicalPlanBuilder.java
@@ -25,6 +25,7 @@ import
org.apache.doris.nereids.trees.expressions.AssertNumRowsElement;
import
org.apache.doris.nereids.trees.expressions.AssertNumRowsElement.Assertion;
import org.apache.doris.nereids.trees.expressions.EqualTo;
import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.MarkJoinSlotReference;
import org.apache.doris.nereids.trees.expressions.NamedExpression;
import org.apache.doris.nereids.trees.plans.DistributeType;
import org.apache.doris.nereids.trees.plans.JoinType;
@@ -49,6 +50,7 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -99,6 +101,17 @@ public class LogicalPlanBuilder {
return from(project);
}
+ public LogicalPlanBuilder markJoin(LogicalPlan right, JoinType joinType,
Pair<Integer, Integer> hashOnSlots) {
+ ImmutableList<EqualTo> hashConjuncts = ImmutableList.of(
+ new EqualTo(this.plan.getOutput().get(hashOnSlots.first),
right.getOutput().get(hashOnSlots.second)));
+
+ LogicalJoin<LogicalPlan, LogicalPlan> join = new
LogicalJoin<>(joinType, new ArrayList<>(hashConjuncts),
+ Collections.emptyList(), Collections.emptyList(),
+ new DistributeHint(DistributeType.NONE), Optional.of(new
MarkJoinSlotReference("fake")),
+ this.plan, right);
+ return from(join);
+ }
+
public LogicalPlanBuilder join(LogicalPlan right, JoinType joinType,
Pair<Integer, Integer> hashOnSlots) {
ImmutableList<EqualTo> hashConjuncts = ImmutableList.of(
new EqualTo(this.plan.getOutput().get(hashOnSlots.first),
right.getOutput().get(hashOnSlots.second)));
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]