You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/11/01 03:13:21 UTC
[GitHub] [doris] starocean999 commented on a diff in pull request #13827: [fix](agg)fix group by constant value bug
starocean999 commented on code in PR #13827:
URL: https://github.com/apache/doris/pull/13827#discussion_r1010035108
##########
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:
yes, originally, this pr is to correct "select 2 from nation group by 1". But as you mentioned, if there is any agg exprs, the grouping exprs can be removed safely, I updated the code to reflect that. thanks.
--
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-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org