[Fix](Planner) fix window function in aggregation (#22603)

Problem:
When window function in aggregation function, executor would report an error like: Required field 'node_type' was not present!

Example:
SELECT SUM(MAX(c1) OVER (PARTITION BY c2, c3)) FROM test_window_in_agg;

Reason:
When analyze aggregate, analytic expr (window function carrior when analyze) transfered to slot and loss message. So when
serialize to thrift package, TExpr can not determine node_type of analytic expr.

Solved:
We do not support aggregate(window function) yet. So we report an error when analyze.
This commit is contained in:
LiBinfeng
2023-08-04 19:15:51 +08:00
committed by GitHub
parent b122f9b80c
commit 265cded7da
2 changed files with 33 additions and 0 deletions

View File

@ -1343,6 +1343,16 @@ public class SelectStmt extends QueryStmt {
}
}
// can't contain analytic exprs
ArrayList<Expr> aggExprsForChecking = Lists.newArrayList();
TreeNode.collect(resultExprs, Expr.isAggregatePredicate(), aggExprsForChecking);
ArrayList<Expr> analyticExprs = Lists.newArrayList();
TreeNode.collect(aggExprsForChecking, AnalyticExpr.class, analyticExprs);
if (!analyticExprs.isEmpty()) {
throw new AnalysisException(
"AGGREGATE clause must not contain analytic expressions");
}
// Collect the aggregate expressions from the SELECT, HAVING and ORDER BY clauses
// of this statement.
ArrayList<FunctionCallExpr> aggExprs = Lists.newArrayList();