This is an automated email from the ASF dual-hosted git repository.

morrysnow pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 6551c30f946 [fix](nereids)aggregate function cannot contain aggregate 
parameters (#30928) (#30982)
6551c30f946 is described below

commit 6551c30f946de4f6cd2ac153d1106f9859fad20e
Author: morrySnow <[email protected]>
AuthorDate: Thu Feb 8 13:46:38 2024 +0800

    [fix](nereids)aggregate function cannot contain aggregate parameters 
(#30928) (#30982)
    
    pick from master #30928
    commit id 5e0dc0c9341bfe6b409acfad1931496eee1f8f82
    
    Co-authored-by: starocean999 
<[email protected]>
---
 .../apache/doris/nereids/rules/analysis/NormalizeAggregate.java    | 6 ++++++
 regression-test/suites/nereids_p0/aggregate/aggregate.groovy       | 7 +++++++
 2 files changed, 13 insertions(+)

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 599a85884e8..1e9cb4f68b7 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
@@ -17,6 +17,7 @@
 
 package org.apache.doris.nereids.rules.analysis;
 
+import org.apache.doris.nereids.exceptions.AnalysisException;
 import org.apache.doris.nereids.rules.Rule;
 import org.apache.doris.nereids.rules.RuleType;
 import org.apache.doris.nereids.rules.rewrite.NormalizeToSlot;
@@ -223,6 +224,11 @@ public class NormalizeAggregate implements 
RewriteRuleFactory, NormalizeToSlot {
         // normalize trival-aggs by bottomProjects
         List<AggregateFunction> normalizedAggFuncs =
                 bottomSlotContext.normalizeToUseSlotRef(aggFuncs);
+        if (normalizedAggFuncs.stream().anyMatch(agg -> 
!agg.children().isEmpty()
+                && agg.child(0).containsType(AggregateFunction.class))) {
+            throw new AnalysisException(
+                    "aggregate function cannot contain aggregate parameters");
+        }
 
         // build normalized agg output
         NormalizeToSlotContext normalizedAggFuncsToSlotContext =
diff --git a/regression-test/suites/nereids_p0/aggregate/aggregate.groovy 
b/regression-test/suites/nereids_p0/aggregate/aggregate.groovy
index f0ba091e045..63b1a7256bb 100644
--- a/regression-test/suites/nereids_p0/aggregate/aggregate.groovy
+++ b/regression-test/suites/nereids_p0/aggregate/aggregate.groovy
@@ -328,4 +328,11 @@ suite("aggregate") {
     assertTrue(plan.contains("max(c_bigint"))
     assertTrue(plan.contains("min(c_bigint"))
     assertTrue(plan.contains("any_value(c_bigint"))
+
+    test {
+        sql """
+              SELECT sum(avg(k1)) FROM tempbaseall;
+            """
+        exception "aggregate function cannot contain aggregate parameters"
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to