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 6a357f22254 [fix](window) only allow 1 argument in count distinct in
window function (#64783)
6a357f22254 is described below
commit 6a357f222546b7c3470368112bd955c08fdce1c6
Author: morrySnow <[email protected]>
AuthorDate: Thu Jun 25 13:34:40 2026 +0800
[fix](window) only allow 1 argument in count distinct in window function
(#64783)
Related PR: #51821
---
.../apache/doris/nereids/rules/rewrite/DistinctWindowExpression.java | 4 ++++
.../suites/query_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/query_p0/multi_distinct/multi_distinct_window.groovy
b/regression-test/suites/query_p0/multi_distinct/multi_distinct_window.groovy
index f7747f488dc..a91cc74ef32 100644
---
a/regression-test/suites/query_p0/multi_distinct/multi_distinct_window.groovy
+++
b/regression-test/suites/query_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]