diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java index e9b3d32da6..e920036247 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/NormalizeAggregate.java @@ -27,6 +27,7 @@ import org.apache.doris.nereids.trees.expressions.ExprId; import org.apache.doris.nereids.trees.expressions.Expression; import org.apache.doris.nereids.trees.expressions.NamedExpression; import org.apache.doris.nereids.trees.expressions.Slot; +import org.apache.doris.nereids.trees.expressions.SlotNotFromChildren; import org.apache.doris.nereids.trees.expressions.SlotReference; import org.apache.doris.nereids.trees.expressions.SubqueryExpr; import org.apache.doris.nereids.trees.expressions.WindowExpression; @@ -269,7 +270,7 @@ public class NormalizeAggregate implements RewriteRuleFactory, NormalizeToSlot { } List errorSlots = new ArrayList<>(slots.size()); for (Slot slot : slots) { - if (!aggOutputExprIds.contains(slot.getExprId())) { + if (!aggOutputExprIds.contains(slot.getExprId()) && !(slot instanceof SlotNotFromChildren)) { errorSlots.add(slot); } } diff --git a/regression-test/data/nereids_function_p0/scalar_function/Array.out b/regression-test/data/nereids_function_p0/scalar_function/Array.out index 0ac1f22144..c6c32bf9b1 100644 --- a/regression-test/data/nereids_function_p0/scalar_function/Array.out +++ b/regression-test/data/nereids_function_p0/scalar_function/Array.out @@ -11976,6 +11976,21 @@ true [1, 1] [1, 1] +-- !sql_array_map_lambda_agg -- +[101] +[102] +[103] +[104] +[105] +[106] +[107] +[108] +[109] +[110] +[111] +[112] +[] + -- !sql_array_exists_Double -- \N [0] diff --git a/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy b/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy index 14a9453632..5b13ed4590 100644 --- a/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy +++ b/regression-test/suites/nereids_function_p0/scalar_function/Array.groovy @@ -1005,6 +1005,8 @@ suite("nereids_scalar_fn_Array") { order_qt_sql_array_map_TinyInt_notnull "select array_map(x -> x is not null, katint) from fn_test_not_nullable" order_qt_sql_array_map_DecimalV3 "select array_map(x -> x is not null, kadcml) from fn_test" order_qt_sql_array_map_DecimalV3_notnull "select array_map(x -> x is not null, kadcml) from fn_test_not_nullable" + order_qt_sql_array_map_lambda_agg "select array_map(x->(x+100), collect_list(ktint)) from fn_test group by id;" + // test array_exists order_qt_sql_array_exists_Double "select array_exists(x -> x > 1, kadbl) from fn_test" order_qt_sql_array_exists_Double_notnull "select array_exists(x -> x > 1, kadbl) from fn_test_not_nullable"