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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new f1ef5a6a335 [fix](planner)output slot should be materialized as 
intermediate slot in agg node #27282 (#27285)
f1ef5a6a335 is described below

commit f1ef5a6a33541e9ce1acfe0952dc1c7ce0af705e
Author: starocean999 <[email protected]>
AuthorDate: Mon Nov 20 20:01:20 2023 +0800

    [fix](planner)output slot should be materialized as intermediate slot in 
agg node #27282 (#27285)
---
 .../org/apache/doris/analysis/AggregateInfo.java   |  1 +
 .../data/correctness_p0/test_agg_materialize.out   |  3 +
 .../correctness_p0/test_agg_materialize.groovy     | 69 ++++++++++++++++++++++
 3 files changed, 73 insertions(+)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java
index 87b3653a199..25851f4b020 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfo.java
@@ -911,6 +911,7 @@ public final class AggregateInfo extends AggregateInfoBase {
                 continue;
             }
 
+            slotDesc.setIsMaterialized(true);
             intermediateSlotDesc.setIsMaterialized(true);
             exprs.add(functionCallExpr);
             materializedSlots.add(i);
diff --git a/regression-test/data/correctness_p0/test_agg_materialize.out 
b/regression-test/data/correctness_p0/test_agg_materialize.out
index 1969d634862..e410945c01c 100644
--- a/regression-test/data/correctness_p0/test_agg_materialize.out
+++ b/regression-test/data/correctness_p0/test_agg_materialize.out
@@ -2,3 +2,6 @@
 -- !select --
 3
 
+-- !select2 --
+1
+qycs
diff --git a/regression-test/suites/correctness_p0/test_agg_materialize.groovy 
b/regression-test/suites/correctness_p0/test_agg_materialize.groovy
index bd8dd1d1133..55711074cf2 100644
--- a/regression-test/suites/correctness_p0/test_agg_materialize.groovy
+++ b/regression-test/suites/correctness_p0/test_agg_materialize.groovy
@@ -32,4 +32,73 @@ suite("test_agg_materialize") {
                         from tb1
                         where e1 = 1)tttt
                     ; """
+    sql """drop table if exists c5749_bug_t;"""
+    sql """CREATE TABLE `c5749_bug_t` (
+            `org_code` varchar(255) NULL ,
+            `cash_amt` decimal(27, 9) NULL ,
+            
+            ) ENGINE=OLAP
+            DUPLICATE KEY(`org_code`)
+            DISTRIBUTED BY HASH(`org_code`) BUCKETS AUTO
+            PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1",
+            "in_memory" = "false",
+            "storage_format" = "V2",
+            "disable_auto_compaction" = "false"
+            );"""
+    sql """insert into c5749_bug_t values('1',1), ('1',2);"""
+    qt_select2 """with SPJ AS (
+                        WITH TOTAL AS (
+                            SELECT
+                                t1.org_code,
+                                round(ifnull(sum(t1.qty), 0) / 10000, 2) qty
+                            FROM
+                                (
+                                    SELECT
+                                        parentOrg.org_code,
+                                        SUM(parentOrg.cash_amt) qty
+                                    FROM
+                                        c5749_bug_t parentOrg 
+                                    GROUP BY
+                                        parentOrg.org_code
+                                    UNION
+                                    ALL
+                                    SELECT
+                                        parentOrg.org_code,
+                                        SUM(parentOrg.cash_amt) qty
+                                    FROM
+                                        c5749_bug_t parentOrg 
+                                    GROUP BY
+                                        parentOrg.org_code
+                                ) t1
+                            GROUP BY
+                                t1.org_code
+                        ),
+                        AGG AS (
+                            SELECT
+                                TOTAL.org_code,
+                                TOTAL.qty totalQty
+                            FROM
+                                TOTAL
+                            UNION
+                            ALL
+                            SELECT
+                                'qycs' org_code,
+                                SUM(TOTAL.qty) totalQty
+                            FROM
+                                TOTAL
+                        )
+                        SELECT
+                            AGG.org_code,
+                            AGG.totalQty AS totalQty
+                        FROM
+                            AGG
+                    )
+                    SELECT
+                        SPJ.org_code
+                    FROM
+                        SPJ
+                    ORDER BY SPJ.org_code;
+                    """
+    sql """drop table if exists c5749_bug_t;"""
 }
\ No newline at end of file


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

Reply via email to