[opt](Nereids) remove restrict for count(*) in window (#35220)

support count(*) used for window function

CREATE TABLE `t1` (
  `id` INT NULL,
  `dt` TEXT NULL
)
DISTRIBUTED BY HASH(`id`) BUCKETS 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);

select *, count(*) over() from t1;
This commit is contained in:
morrySnow
2024-05-23 10:46:50 +08:00
committed by yiguolei
parent 8c594c6959
commit 98b2bda660
5 changed files with 57 additions and 90 deletions

View File

@ -2063,7 +2063,7 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
List<UnboundStar> unboundStars = ExpressionUtils.collectAll(params, UnboundStar.class::isInstance);
if (!unboundStars.isEmpty()) {
if (functionName.equalsIgnoreCase("count")) {
if (ctx.functionIdentifier().dbName == null && functionName.equalsIgnoreCase("count")) {
if (unboundStars.size() > 1) {
throw new ParseException(
"'*' can only be used once in conjunction with COUNT: " + functionName, ctx);
@ -2072,9 +2072,10 @@ public class LogicalPlanBuilder extends DorisParserBaseVisitor<Object> {
throw new ParseException("'*' can not has qualifier: " + unboundStars.size(), ctx);
}
if (ctx.windowSpec() != null) {
// todo: support count(*) as window function
throw new ParseException(
"COUNT(*) isn't supported as window function; can use COUNT(col)", ctx);
if (isDistinct) {
throw new ParseException("DISTINCT not allowed in analytic function: " + functionName, ctx);
}
return withWindowSpec(ctx.windowSpec(), new Count());
}
return new Count();
}