Skip to content

Commit

Permalink
[Enhancement] add sv to control derive join is null predicate (StarRo…
Browse files Browse the repository at this point in the history
…cks#36649)

Signed-off-by: yanz <[email protected]>
  • Loading branch information
dirtysalt authored Dec 20, 2023
1 parent 75a3a42 commit 1d58759
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -2896,6 +2901,10 @@ public void setCboDeriveRangeJoinPredicate(boolean cboDeriveRangeJoinPredicate)
this.cboDeriveRangeJoinPredicate = cboDeriveRangeJoinPredicate;
}

public boolean isCboDeriveJoinIsNullPredicate() {
return cboDeriveJoinIsNullPredicate;
}

public boolean isAuditExecuteStmt() {
return auditExecuteStmt;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -306,6 +307,10 @@ private void pushDownPredicateByFilter(
private void deriveIsNotNullPredicate(
List<BinaryPredicateOperator> onEQPredicates, OptExpression join,
List<ScalarOperator> leftPushDown, List<ScalarOperator> rightPushDown) {
if (!ConnectContext.get().getSessionVariable().isCboDeriveJoinIsNullPredicate()) {
return;
}

List<ScalarOperator> leftEQ = Lists.newArrayList();
List<ScalarOperator> rightEQ = Lists.newArrayList();

Expand All @@ -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);
Expand Down

0 comments on commit 1d58759

Please sign in to comment.