Skip to content

Commit

Permalink
[FE](session-variable) Add a debug variable of constant fold (#35584)
Browse files Browse the repository at this point in the history
which force skip constant fold in nereids. make it easier for test,
especially for SqlLogic platform
  • Loading branch information
zclllyybb authored and LiBinfeng-01 committed Oct 8, 2024
1 parent 2be0f8f commit ff43dad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ public class FoldConstantRuleOnBE extends AbstractExpressionRewriteRule {

@Override
public Expression rewrite(Expression expr, ExpressionRewriteContext ctx) {
Expression expression = FoldConstantRuleOnFE.INSTANCE.rewrite(expr, ctx);
if(ctx.cascadesContext.getConnectContext().getSessionVariable().isDebugSkipFoldConstant()) {
return null;
}
Expression expression = FoldConstantRuleOnFE.INSTANCE.rewrite(expr, ctx);
return foldByBE(expression, ctx);
}

Expand Down
27 changes: 27 additions & 0 deletions fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public class SessionVariable implements Serializable, Writable {
public static final String PREFER_JOIN_METHOD = "prefer_join_method";

public static final String ENABLE_FOLD_CONSTANT_BY_BE = "enable_fold_constant_by_be";
public static final String DEBUG_SKIP_FOLD_CONSTANT = "debug_skip_fold_constant";

public static final String ENABLE_ODBC_TRANSCATION = "enable_odbc_transcation";
public static final String ENABLE_SQL_CACHE = "enable_sql_cache";
public static final String ENABLE_PARTITION_CACHE = "enable_partition_cache";
Expand Down Expand Up @@ -805,7 +807,13 @@ public class SessionVariable implements Serializable, Writable {
private boolean enableJoinReorderBasedCost = false;

@VariableMgr.VarAttr(name = ENABLE_FOLD_CONSTANT_BY_BE, fuzzy = true)
<<<<<<< HEAD
private boolean enableFoldConstantByBe = false;
=======
public boolean enableFoldConstantByBe = true;
@VariableMgr.VarAttr(name = DEBUG_SKIP_FOLD_CONSTANT)
public boolean debugSkipFoldConstant = false;
>>>>>>> 94db52c820 ([FE](session-variable) Add a debug variable of constant fold (#35584))

@VariableMgr.VarAttr(name = RUNTIME_FILTER_MODE, needForward = true)
private String runtimeFilterMode = "GLOBAL";
Expand Down Expand Up @@ -1933,6 +1941,21 @@ public boolean isEnableFoldConstantByBe() {
return enableFoldConstantByBe;
}

<<<<<<< HEAD
=======
public boolean isDebugSkipFoldConstant() {
return debugSkipFoldConstant;
}

public boolean isEnableRewriteElementAtToSlot() {
return enableRewriteElementAtToSlot;
}

public void setEnableRewriteElementAtToSlot(boolean rewriteElementAtToSlot) {
enableRewriteElementAtToSlot = rewriteElementAtToSlot;
}

>>>>>>> 94db52c820 ([FE](session-variable) Add a debug variable of constant fold (#35584))
public boolean isEnableNereidsDML() {
return enableNereidsDML;
}
Expand All @@ -1941,6 +1964,10 @@ public void setEnableFoldConstantByBe(boolean foldConstantByBe) {
this.enableFoldConstantByBe = foldConstantByBe;
}

public void setDebugSkipFoldConstant(boolean debugSkipFoldConstant) {
this.debugSkipFoldConstant = debugSkipFoldConstant;
}

public int getParallelExecInstanceNum() {
ConnectContext connectContext = ConnectContext.get();
if (connectContext != null && connectContext.getEnv() != null && connectContext.getEnv().getAuth() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,8 @@ private void analyzeAndGenerateQueryPlan(TQueryOptions tQueryOptions) throws Use
if (parsedStmt instanceof QueryStmt || parsedStmt instanceof InsertStmt) {
ExprRewriter rewriter = analyzer.getExprRewriter();
rewriter.reset();
if (context.getSessionVariable().isEnableFoldConstantByBe()) {
if (context.getSessionVariable().isEnableFoldConstantByBe()
&& !context.getSessionVariable().isDebugSkipFoldConstant()) {
// fold constant expr
parsedStmt.foldConstant(rewriter, tQueryOptions);

Expand Down

0 comments on commit ff43dad

Please sign in to comment.