[fix](Nereids) some special expression should not be constant (#30305)
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
@ -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','2014-10-05 00:00:00.111111','2014-10-05 00:00:00.111111'),('JDR',14.03,'2014-10-06 00:00:00','2014-10-06 00:00:00.111111','2014-10-06 00:00:00.111111','2014-10-06 00:00:00.111111'),('JDR',14.75,'2014-10-07 00:00:00','2014-10-07 00:00:00.111111','2014-10-07 00:00:00.111111','2014-10-07 00:00:00.111111'),('JDR',13.98,'2014-10-08 00:00:00','2014-10-08 00:00:00.111111','2014-10-08 00:00:00.111111','2014-10-08 00:00:00.111111') """
|
||||
|
||||
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) */
|
||||
|
||||
Reference in New Issue
Block a user