This is an automated email from the ASF dual-hosted git repository. morrysnow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new cd6a6c0de2e [fix](Nereids) some special expression should not be constant (#30305) cd6a6c0de2e is described below commit cd6a6c0de2e6a515c8b373bbdd7113edc27634d5 Author: morrySnow <101034200+morrys...@users.noreply.github.com> AuthorDate: Thu Jan 25 15:58:19 2024 +0800 [fix](Nereids) some special expression should not be constant (#30305) --- .../doris/nereids/trees/expressions/Expression.java | 18 +++++++++++++++++- .../window_functions/test_window_function.groovy | 4 ++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java index 048cae55f3d..246cbbf8969 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/Expression.java @@ -18,18 +18,22 @@ package org.apache.doris.nereids.trees.expressions; import org.apache.doris.common.Config; +import org.apache.doris.nereids.analyzer.PlaceholderExpression; import org.apache.doris.nereids.analyzer.Unbound; +import org.apache.doris.nereids.analyzer.UnboundVariable; import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.trees.AbstractTreeNode; import org.apache.doris.nereids.trees.expressions.functions.ExpressionTrait; import org.apache.doris.nereids.trees.expressions.functions.Nondeterministic; import org.apache.doris.nereids.trees.expressions.functions.agg.AggregateFunction; +import org.apache.doris.nereids.trees.expressions.functions.scalar.Lambda; import org.apache.doris.nereids.trees.expressions.literal.Literal; import org.apache.doris.nereids.trees.expressions.literal.NullLiteral; import org.apache.doris.nereids.trees.expressions.shape.LeafExpression; import org.apache.doris.nereids.trees.expressions.typecoercion.ExpectsInputTypes; import org.apache.doris.nereids.trees.expressions.typecoercion.TypeCheckResult; import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor; +import org.apache.doris.nereids.trees.plans.commands.info.PartitionDefinition.MaxValue; import org.apache.doris.nereids.types.ArrayType; import org.apache.doris.nereids.types.DataType; import org.apache.doris.nereids.types.MapType; @@ -249,7 +253,19 @@ public abstract class Expression extends AbstractTreeNode<Expression> implements * Whether the expression is a constant. */ public boolean isConstant() { - if (this instanceof AggregateFunction) { + if (this instanceof AssertNumRowsElement + || this instanceof AggregateFunction + || this instanceof Lambda + || this instanceof MaxValue + || this instanceof OrderExpression + || this instanceof PlaceholderExpression + || this instanceof Properties + || this instanceof SubqueryExpr + || this instanceof UnboundVariable + || this instanceof Variable + || this instanceof VariableDesc + || this instanceof WindowExpression + || this instanceof WindowFrame) { // agg_fun(literal) is not constant, the result depends on the group by keys return false; } diff --git a/regression-test/suites/nereids_p0/sql_functions/window_functions/test_window_function.groovy b/regression-test/suites/nereids_p0/sql_functions/window_functions/test_window_function.groovy index 26b770e8687..bcaaefe7031 100644 --- a/regression-test/suites/nereids_p0/sql_functions/window_functions/test_window_function.groovy +++ b/regression-test/suites/nereids_p0/sql_functions/window_functions/test_window_function.groovy @@ -25,6 +25,10 @@ suite("test_window_function") { sql """ INSERT INTO ${windowFunctionTable1} VALUES ('JDR',12.86,'2014-10-02 00:00:00','2014-10-02 00:00:00.111111','2014-10-02 00:00:00.111111','2014-10-02 00:00:00.111111'),('JDR',12.89,'2014-10-03 00:00:00','2014-10-03 00:00:00.111111','2014-10-03 00:00:00.111111','2014-10-03 00:00:00.111111'),('JDR',12.94,'2014-10-04 00:00:00','2014-10-04 00:00:00.111111','2014-10-04 00:00:00.111111','2014-10-04 00:00:00.111111'),('JDR',12.55,'2014-10-05 00:00:00','2014-10-05 00:00:00.111111','201 [...] qt_sql """SELECT row_number() OVER (partition by 1 order by 2) from ${windowFunctionTable1} order by 1; """ + + // test constant folding by be on OrderExpression + sql """set enable_fold_constant_by_be = true""" + sql """SELECT row_number() OVER (partition by 1 order by 2) from ${windowFunctionTable1} order by 1; """ // Nereids does't support window function // qt_sql """ // SELECT /*+SET_VAR(parallel_fragment_exec_instance_num=1) */ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org