[FIX](agg)fix group by constant child expr bug (#13485)
This commit is contained in:
@ -93,20 +93,12 @@ public class GroupByClause implements ParseNode {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
groupingExprs = new ArrayList<>();
|
||||
analyzed = false;
|
||||
exprGenerated = false;
|
||||
if (groupingType != GroupingType.GROUP_BY) {
|
||||
groupingExprs = new ArrayList<>();
|
||||
if (oriGroupingExprs != null) {
|
||||
Expr.resetList(oriGroupingExprs);
|
||||
groupingExprs.addAll(oriGroupingExprs);
|
||||
}
|
||||
} else {
|
||||
if (groupingExprs != null) {
|
||||
for (Expr e : groupingExprs) {
|
||||
e.reset();
|
||||
}
|
||||
}
|
||||
if (oriGroupingExprs != null) {
|
||||
Expr.resetList(oriGroupingExprs);
|
||||
groupingExprs.addAll(oriGroupingExprs);
|
||||
}
|
||||
if (groupingSetList != null) {
|
||||
for (List<Expr> s : groupingSetList) {
|
||||
|
||||
@ -1389,7 +1389,19 @@ public class SelectStmt extends QueryStmt {
|
||||
}
|
||||
List<Expr> oriGroupingExprs = groupByClause.getOriGroupingExprs();
|
||||
if (oriGroupingExprs != null) {
|
||||
// we must make sure the expr is analyzed before rewrite
|
||||
try {
|
||||
for (Expr expr : oriGroupingExprs) {
|
||||
expr.analyze(analyzer);
|
||||
}
|
||||
} catch (AnalysisException ex) {
|
||||
//ignore any exception
|
||||
}
|
||||
rewriter.rewriteList(oriGroupingExprs, analyzer);
|
||||
// after rewrite, need reset the analyze status for later re-analyze
|
||||
for (Expr expr : oriGroupingExprs) {
|
||||
expr.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (orderByElements != null) {
|
||||
|
||||
Reference in New Issue
Block a user