From bd978daa5884114308f2f4bca7424a2f19946b08 Mon Sep 17 00:00:00 2001 From: LiBinfeng <46676950+LiBinfeng-01@users.noreply.github.com> Date: Wed, 16 Aug 2023 16:46:26 +0800 Subject: [PATCH] [Fix](Planner) fix multi phase analysis failed in multi instance environment substitution (#22840) Problem: When executing group_concat with order by inside in view, column can not be found when analyze. Example: create view if not exists test_view as select group_concat(c1,',' order by c1 asc) from table_group_concat; select * from test_view; it will return an error like: "can not find c1 in table_list" Reason: When we executing this sql in multi-instance environment, Planner would try to create plan in multi phase aggregation. And because we analyze test_view independent with tables outside view. So we can not get table informations inside view. Solution: Substitute order by expression of merge aggregation expressions. --- .../main/java/org/apache/doris/planner/AggregationNode.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java b/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java index e4e3170379dadd..5d00144f05c605 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/AggregationNode.java @@ -176,6 +176,9 @@ public void init(Analyzer analyzer) throws UserException { // to our input; our conjuncts don't get substituted because they already // refer to our output outputSmap = getCombinedChildSmap(); + if (aggInfo.isMerge()) { + aggInfo.substitute(aggInfo.getIntermediateSmap(), analyzer); + } aggInfo.substitute(outputSmap, analyzer); // assert consistent aggregate expr and slot materialization