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

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


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 8a31b2ba727 branch-4.1: [fix](window) only allow 1 argument in count 
distinct in window function #64783 (#64824)
8a31b2ba727 is described below

commit 8a31b2ba727ccaaea7dccc9204473b3466616027
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Jun 25 17:48:43 2026 +0800

    branch-4.1: [fix](window) only allow 1 argument in count distinct in window 
function #64783 (#64824)
    
    Cherry-picked from #64783
    
    Co-authored-by: morrySnow <[email protected]>
---
 .../apache/doris/nereids/rules/rewrite/DistinctWindowExpression.java | 4 ++++
 .../suites/nereids_p0/multi_distinct/multi_distinct_window.groovy    | 5 +++++
 2 files changed, 9 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/DistinctWindowExpression.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/DistinctWindowExpression.java
index 81daf82e986..fd75e5382fc 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/DistinctWindowExpression.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/rewrite/DistinctWindowExpression.java
@@ -17,6 +17,7 @@
 
 package org.apache.doris.nereids.rules.rewrite;
 
+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.trees.expressions.Alias;
@@ -86,6 +87,9 @@ public class DistinctWindowExpression extends 
OneRewriteRuleFactory {
     private Optional<AggregateFunction> 
convertToMultiDistinctFunction(AggregateFunction func) {
         if (func.isDistinct()) {
             if (func instanceof Count) {
+                if (func.arity() != 1) {
+                    throw new AnalysisException("COUNT with DISTINCT only 
support 1 parameter in analytic function");
+                }
                 return Optional.of(new MultiDistinctCount(false, 
func.child(0)));
             } else if (func instanceof Sum) {
                 return Optional.of(new MultiDistinctSum(false, ((Sum) 
func).child()));
diff --git 
a/regression-test/suites/nereids_p0/multi_distinct/multi_distinct_window.groovy 
b/regression-test/suites/nereids_p0/multi_distinct/multi_distinct_window.groovy
index f7747f488dc..a91cc74ef32 100644
--- 
a/regression-test/suites/nereids_p0/multi_distinct/multi_distinct_window.groovy
+++ 
b/regression-test/suites/nereids_p0/multi_distinct/multi_distinct_window.groovy
@@ -42,4 +42,9 @@ suite('multi_distinct_window') {
 
     qt_distinct_group_concat "select id, v1, group_concat(distinct v2) over() 
from multi order by id;"
 
+    test {
+        sql """select id, count(distinct v1, v2) over() from multi order by 
id;"""
+        exception "COUNT with DISTINCT only support 1 parameter in analytic 
function"
+    }
+
 }
\ No newline at end of file


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

Reply via email to