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 11, 2024
1 parent 2be0f8f commit 93eed85
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public class FoldConstantRuleOnBE extends AbstractExpressionRewriteRule {

@Override
public Expression rewrite(Expression expr, ExpressionRewriteContext ctx) {
if (ctx.cascadesContext.getConnectContext().getSessionVariable().isDebugSkipFoldConstant()) {
return null;
}
Expression expression = FoldConstantRuleOnFE.INSTANCE.rewrite(expr, ctx);
return foldByBE(expression, ctx);
}
Expand Down
13 changes: 13 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 @@ -807,6 +809,9 @@ public class SessionVariable implements Serializable, Writable {
@VariableMgr.VarAttr(name = ENABLE_FOLD_CONSTANT_BY_BE, fuzzy = true)
private boolean enableFoldConstantByBe = false;

@VariableMgr.VarAttr(name = DEBUG_SKIP_FOLD_CONSTANT)
public boolean debugSkipFoldConstant = false;

@VariableMgr.VarAttr(name = RUNTIME_FILTER_MODE, needForward = true)
private String runtimeFilterMode = "GLOBAL";

Expand Down Expand Up @@ -1933,6 +1938,10 @@ public boolean isEnableFoldConstantByBe() {
return enableFoldConstantByBe;
}

public boolean isDebugSkipFoldConstant() {
return debugSkipFoldConstant;
}

public boolean isEnableNereidsDML() {
return enableNereidsDML;
}
Expand All @@ -1941,6 +1950,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 93eed85

Please sign in to comment.