This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new bf37e5c905c [feature](Nereids) support select distinct with aggregate
(#35300)
bf37e5c905c is described below
commit bf37e5c905c29515a631f39cf150507fa95770dd
Author: 924060929 <[email protected]>
AuthorDate: Thu May 23 19:01:10 2024 +0800
[feature](Nereids) support select distinct with aggregate (#35300)
(cherry picked from commit adcbc8cce57aaec507174f39536a028db803a2e5)
---
.../java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java | 4 ----
regression-test/suites/nereids_syntax_p0/window_function.groovy | 9 +++++++++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
index 2263951e097..4df2a50eca9 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java
@@ -2904,10 +2904,6 @@ public class LogicalPlanBuilder extends
DorisParserBaseVisitor<Object> {
SelectColumnClauseContext selectColumnCtx =
selectClause.selectColumnClause();
LogicalPlan aggregate = withAggregate(filter, selectColumnCtx,
aggClause);
boolean isDistinct = (selectClause.DISTINCT() != null);
- if (isDistinct && aggregate instanceof Aggregate) {
- throw new ParseException("cannot combine SELECT DISTINCT with
aggregate functions or GROUP BY",
- selectClause);
- }
if (!(aggregate instanceof Aggregate) && havingClause.isPresent())
{
// create a project node for pattern match of
ProjectToGlobalAggregate rule
// then ProjectToGlobalAggregate rule can insert agg node as
LogicalHaving node's child
diff --git a/regression-test/suites/nereids_syntax_p0/window_function.groovy
b/regression-test/suites/nereids_syntax_p0/window_function.groovy
index 538038c7744..209729b9358 100644
--- a/regression-test/suites/nereids_syntax_p0/window_function.groovy
+++ b/regression-test/suites/nereids_syntax_p0/window_function.groovy
@@ -192,4 +192,13 @@ suite("window_function") {
left join adj_nullable_2 on c1 = c4
where c6 is not null;
"""
+
+ // distinct with window
+ sql """
+ SELECT
+ DISTINCT dt,
+ count(dt2) over (partition by dt) as num
+ from
+ (select 1 as dt,2 as dt2)t
+ group by dt,dt2"""
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]