[fix](agg)fix group by constant value bug (#13827)

* [fix](agg)fix group by constant value bug

* keep only one const grouping exprs if no agg exprs
This commit is contained in:
starocean999
2022-11-03 10:26:59 +08:00
committed by GitHub
parent 5a700223fe
commit a4a991207b
2 changed files with 6 additions and 25 deletions

View File

@ -1092,8 +1092,13 @@ public class SelectStmt extends QueryStmt {
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() && aggExprs.isEmpty()) {
// should keep at least one expr to make the result correct
groupingExprs.add(tempExprs.get(0));
}
}
if (groupingInfo != null) {

View File

@ -1,28 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !runConstantGroupBy_order --
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2