This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new bfa40a0f7a [Fix](planner) cherry-pick prs to branch 1.2 (#23544)
bfa40a0f7a is described below

commit bfa40a0f7adab536df34324cc42a2b2a7ed371cc
Author: LiBinfeng <[email protected]>
AuthorDate: Mon Aug 28 10:53:07 2023 +0800

    [Fix](planner) cherry-pick prs to branch 1.2 (#23544)
    
    cherry-pick from master
    pr22196
    pr22840
---
 .../org/apache/doris/analysis/FunctionCallExpr.java   | 19 ++++++++++++++++---
 .../org/apache/doris/planner/AggregationNode.java     |  3 +++
 .../data/query_p0/group_concat/test_group_concat.out  |  5 ++++-
 .../query_p0/group_concat/test_group_concat.groovy    |  7 ++++++-
 4 files changed, 29 insertions(+), 5 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index 76c2fe825a..07785f47ac 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -544,10 +544,18 @@ public class FunctionCallExpr extends Expr {
             len = len - 1;
         }
         for (int i = 0; i < len; ++i) {
+            if (i != 0) {
+                if (fnName.getFunction().equalsIgnoreCase("group_concat")
+                        && orderByElements.size() > 0 && i == len - 
orderByElements.size()) {
+                    sb.append(" ");
+                } else {
+                    sb.append(", ");
+                }
+            }
             if (i == 1 && (fnName.getFunction().equalsIgnoreCase("aes_decrypt")
-                    || fnName.getFunction().equalsIgnoreCase("aes_encrypt")
-                    || fnName.getFunction().equalsIgnoreCase("sm4_decrypt")
-                    || fnName.getFunction().equalsIgnoreCase("sm4_encrypt"))) {
+                || fnName.getFunction().equalsIgnoreCase("aes_encrypt")
+                || fnName.getFunction().equalsIgnoreCase("sm4_decrypt")
+                || fnName.getFunction().equalsIgnoreCase("sm4_encrypt"))) {
                 result.add("\'***\'");
             } else if (orderByElements.size() > 0 && i == len - 
orderByElements.size()) {
                 result.add("ORDER BY " + children.get(i).toSql());
@@ -1577,6 +1585,11 @@ public class FunctionCallExpr extends Expr {
         }
         // rewrite return type if is nested type function
         analyzeNestedFunction();
+        for (OrderByElement o : orderByElements) {
+            if (!o.getExpr().isAnalyzed) {
+                o.getExpr().analyzeImpl(analyzer);
+            }
+        }
     }
 
     // if return type is nested type, need to be determined the sub-element 
type
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 685430cd5c..9be1262c38 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 class AggregationNode extends PlanNode {
         // 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
diff --git a/regression-test/data/query_p0/group_concat/test_group_concat.out 
b/regression-test/data/query_p0/group_concat/test_group_concat.out
index 0bc76e1146..4bbe069046 100644
--- a/regression-test/data/query_p0/group_concat/test_group_concat.out
+++ b/regression-test/data/query_p0/group_concat/test_group_concat.out
@@ -49,6 +49,9 @@ false
 1      3, 21, 2, 11, 1
 2      23, 222, 22, 211, 21
 
--- !select_group_concat_order_by --
+-- !select_group_concat_order_by1 --
+1,11,2,21,21,211,22,222,23,3   3,23,222,22,211,21,21,2,11,1
+
+-- !select_group_concat_order_by2 --
 1,11,2,21,21,211,22,222,23,3   3,23,222,22,211,21,21,2,11,1
 
diff --git 
a/regression-test/suites/query_p0/group_concat/test_group_concat.groovy 
b/regression-test/suites/query_p0/group_concat/test_group_concat.groovy
index f2d5dd3504..bb8d5328cc 100644
--- a/regression-test/suites/query_p0/group_concat/test_group_concat.groovy
+++ b/regression-test/suites/query_p0/group_concat/test_group_concat.groovy
@@ -62,8 +62,13 @@ suite("test_group_concat") {
     qt_select_group_concat_order_by_desc3 """
                 SELECT b1, group_concat(cast(abs(b3) as varchar) order by 
abs(b2) desc, b3 desc) FROM table_group_concat  group by b1 order by b1
               """
-    qt_select_group_concat_order_by """
+    qt_select_group_concat_order_by1 """
                 select group_concat(b3,',' order by b3 
asc),group_concat(b3,',' order by b3 desc) from table_group_concat;
     """
 
+    sql """create view if not exists test_view as select group_concat(b3,',' 
order by b3 asc),group_concat(b3,',' order by b3 desc) from 
table_group_concat;"""
+    qt_select_group_concat_order_by2 """
+                select * from test_view;
+    """
+    sql """drop view if exists test_view"""
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to