[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:
@ -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) {
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user