[fix](fe)ordering exprs should be substituted in the same way as select part (#20091)

This commit is contained in:
starocean999
2023-05-27 21:00:57 +08:00
committed by GitHub
parent ac8599fedb
commit 4cbb6ece10
3 changed files with 10 additions and 1 deletions

View File

@ -1366,6 +1366,10 @@ public class SelectStmt extends QueryStmt {
havingClauseAfterAnaylzed =
havingClauseAfterAnaylzed.substitute(countAllMap, analyzer, false);
}
if (sortInfo != null) {
// the ordering exprs must substitute in the same way as resultExprs
sortInfo.substituteOrderingExprs(countAllMap, analyzer);
}
aggExprs.clear();
TreeNode.collect(substitutedAggs, Expr.isAggregatePredicate(), aggExprs);

View File

@ -7,3 +7,6 @@ all 2
-- !select2 --
1.0 1
-- !select3 --
1.0 1

View File

@ -54,7 +54,9 @@
"""
sql """insert into cf_member values(2, 2, '2'); """
qt_select2 """select floor(id-1.0), count(*) from cf_member cm group by floor(id-1.0);"""
qt_select2 """select floor(id-1.0), count(*) from cf_member cm group by floor(id-1.0) order by floor(id-1.0);"""
qt_select3 """select floor(id-1.0), count(*) from cf_member cm group by 1 order by 1;"""
sql """DROP TABLE IF EXISTS `cf_member`; """
}