diff --git a/fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java b/fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java index d00b8f4b2b630..cdb61f5df3374 100644 --- a/fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java +++ b/fe/fe-core/src/main/java/com/starrocks/qe/SessionVariable.java @@ -582,6 +582,8 @@ public static MaterializedViewRewriteMode parse(String str) { public static final String CBO_DERIVE_RANGE_JOIN_PREDICATE = "cbo_derive_range_join_predicate"; + public static final String CBO_DERIVE_JOIN_IS_NULL_PREDICATE = "cbo_derive_join_is_null_predicate"; + public static final String CBO_DECIMAL_CAST_STRING_STRICT = "cbo_decimal_cast_string_strict"; public static final String CBO_EQ_BASE_TYPE = "cbo_eq_base_type"; @@ -1515,6 +1517,9 @@ public SessionVariable setHiveTempStagingDir(String hiveTempStagingDir) { @VarAttr(name = CBO_DERIVE_RANGE_JOIN_PREDICATE) private boolean cboDeriveRangeJoinPredicate = false; + @VarAttr(name = CBO_DERIVE_JOIN_IS_NULL_PREDICATE) + private boolean cboDeriveJoinIsNullPredicate = true; + @VarAttr(name = CBO_DECIMAL_CAST_STRING_STRICT, flag = VariableMgr.INVISIBLE) private boolean cboDecimalCastStringStrict = true; @@ -2896,6 +2901,10 @@ public void setCboDeriveRangeJoinPredicate(boolean cboDeriveRangeJoinPredicate) this.cboDeriveRangeJoinPredicate = cboDeriveRangeJoinPredicate; } + public boolean isCboDeriveJoinIsNullPredicate() { + return cboDeriveJoinIsNullPredicate; + } + public boolean isAuditExecuteStmt() { return auditExecuteStmt; } diff --git a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/JoinPredicatePushdown.java b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/JoinPredicatePushdown.java index 5ae76f835eae9..88157568d9cd7 100644 --- a/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/JoinPredicatePushdown.java +++ b/fe/fe-core/src/main/java/com/starrocks/sql/optimizer/rewrite/JoinPredicatePushdown.java @@ -19,6 +19,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.starrocks.analysis.JoinOperator; +import com.starrocks.qe.ConnectContext; import com.starrocks.sql.optimizer.JoinHelper; import com.starrocks.sql.optimizer.OptExpression; import com.starrocks.sql.optimizer.Utils; @@ -306,6 +307,10 @@ private void pushDownPredicateByFilter( private void deriveIsNotNullPredicate( List onEQPredicates, OptExpression join, List leftPushDown, List rightPushDown) { + if (!ConnectContext.get().getSessionVariable().isCboDeriveJoinIsNullPredicate()) { + return; + } + List leftEQ = Lists.newArrayList(); List rightEQ = Lists.newArrayList(); @@ -324,6 +329,7 @@ private void deriveIsNotNullPredicate( } LogicalJoinOperator joinOp = ((LogicalJoinOperator) join.getOp()); + JoinOperator joinType = joinOp.getJoinType(); if ((joinType.isInnerJoin() || joinType.isRightSemiJoin()) && leftPushDown.isEmpty()) { leftEQ.stream().map(c -> new IsNullPredicateOperator(true, c.clone(), true)).forEach(leftPushDown::add);