diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java index 1739c147d8678d0..07af21c3392d31d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/FoldConstantRuleOnBE.java @@ -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); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java index 8a5c3a85055b88a..9879986438aedd1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java @@ -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"; @@ -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"; @@ -1933,6 +1938,10 @@ public boolean isEnableFoldConstantByBe() { return enableFoldConstantByBe; } + public boolean isDebugSkipFoldConstant() { + return debugSkipFoldConstant; + } + public boolean isEnableNereidsDML() { return enableNereidsDML; } @@ -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) { diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java index 02b0872fe6b4dc9..f9131ce1b450564 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java @@ -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);