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 76bd59970856d4..2fc10a2c0619b4 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 @@ -2896,10 +2896,6 @@ private LogicalPlan withSelectQuerySpecification( 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 538038c774488c..209729b935894b 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""" }