You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/10/31 00:50:39 UTC
[doris] branch branch-1.1-lts updated: [fix](plan)result exprs should be substituted in the same way as agg exprs (#13757)
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-1.1-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.1-lts by this push:
new 6e92aa34ca [fix](plan)result exprs should be substituted in the same way as agg exprs (#13757)
6e92aa34ca is described below
commit 6e92aa34ca4bf2e351db5c4d6b1d24a344289204
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Mon Oct 31 08:50:33 2022 +0800
[fix](plan)result exprs should be substituted in the same way as agg exprs (#13757)
* [fix](plan)result exprs should be substituted in the same way as agg exprs
* remove unused code
---
.../java/org/apache/doris/analysis/SelectStmt.java | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
index 2fe58db9ec..2cc192b9d1 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/SelectStmt.java
@@ -1062,6 +1062,9 @@ public class SelectStmt extends QueryStmt {
countAllMap = ExprSubstitutionMap.compose(multiCountOrSumDistinctMap, countAllMap, analyzer);
List<Expr> substitutedAggs =
Expr.substituteList(aggExprs, countAllMap, analyzer, false);
+ // the resultExprs must substitute in the same way as aggExprs
+ // then resultExprs can be substitute correctly using combinedSmap
+ resultExprs = Expr.substituteList(resultExprs, countAllMap, analyzer, false);
aggExprs.clear();
TreeNode.collect(substitutedAggs, Expr.isAggregatePredicate(), aggExprs);
@@ -1395,7 +1398,11 @@ public class SelectStmt extends QueryStmt {
// we must make sure the expr is analyzed before rewrite
try {
for (Expr expr : oriGroupingExprs) {
- expr.analyze(analyzer);
+ if (!(expr instanceof SlotRef)) {
+ // if group expr is not a slotRef, it should be analyzed in the same way as result expr
+ // otherwise, the group expr is either a simple column or an alias, no need to analyze
+ expr.analyze(analyzer);
+ }
}
} catch (AnalysisException ex) {
//ignore any exception
@@ -1403,7 +1410,9 @@ public class SelectStmt extends QueryStmt {
rewriter.rewriteList(oriGroupingExprs, analyzer);
// after rewrite, need reset the analyze status for later re-analyze
for (Expr expr : oriGroupingExprs) {
- expr.reset();
+ if (!(expr instanceof SlotRef)) {
+ expr.reset();
+ }
}
}
}
@@ -1411,13 +1420,20 @@ public class SelectStmt extends QueryStmt {
for (OrderByElement orderByElem : orderByElements) {
// we must make sure the expr is analyzed before rewrite
try {
- orderByElem.getExpr().analyze(analyzer);
+ if (!(orderByElem.getExpr() instanceof SlotRef)) {
+ // if sort expr is not a slotRef, it should be analyzed in the same way as result expr
+ // otherwise, the sort expr is either a simple column or an alias, no need to analyze
+ orderByElem.getExpr().analyze(analyzer);
+ }
} catch (AnalysisException ex) {
//ignore any exception
}
orderByElem.setExpr(rewriter.rewrite(orderByElem.getExpr(), analyzer));
// after rewrite, need reset the analyze status for later re-analyze
orderByElem.getExpr().reset();
+ if (!(orderByElem.getExpr() instanceof SlotRef)) {
+ orderByElem.getExpr().reset();
+ }
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org