morrySnow commented on code in PR #13827: URL: https://github.com/apache/doris/pull/13827#discussion_r1010019843
########## fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java: ########## @@ -1068,8 +1068,13 @@ private void analyzeAggregation(Analyzer analyzer) throws AnalysisException { substituteOrdinalsAliases(groupingExprs, "GROUP BY", analyzer); - if (!groupByClause.isGroupByExtension()) { + if (!groupByClause.isGroupByExtension() && !groupingExprs.isEmpty()) { + ArrayList<Expr> tempExprs = new ArrayList<>(groupingExprs); groupingExprs.removeIf(Expr::isConstant); + if (groupingExprs.isEmpty()) { + // should keep at least one expr to make the result correct + groupingExprs.add(tempExprs.get(0)); Review Comment: why we need to keep one? i think ``` select sum(a) from t group by 2 ``` is same with ``` select sum(a) from t ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org