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-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

Reply via email to