You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by st...@apache.org on 2023/11/23 10:41:16 UTC

(doris) branch master updated: [fix](planner)output slot should be materialized as intermediate slot in agg node (#27282)

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

starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


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

commit d9f6e51884e8f6f34c268b50eb4cd346556ea806
Author: starocean999 <40...@users.noreply.github.com>
AuthorDate: Thu Nov 23 18:41:08 2023 +0800

    [fix](planner)output slot should be materialized as intermediate slot in agg node (#27282)
---
 .../org/apache/doris/analysis/AggregateInfo.java   |  1 +
 .../data/correctness_p0/test_agg_materialize.out   |  4 ++
 .../correctness_p0/test_agg_materialize.groovy     | 69 ++++++++++++++++++++++
 3 files changed, 74 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..26c36a0045e 100644
--- a/regression-test/data/correctness_p0/test_agg_materialize.out
+++ b/regression-test/data/correctness_p0/test_agg_materialize.out
@@ -2,3 +2,7 @@
 -- !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 7911231ed40..3f79013ea01 100644
--- a/regression-test/suites/correctness_p0/test_agg_materialize.groovy
+++ b/regression-test/suites/correctness_p0/test_agg_materialize.groovy
@@ -31,4 +31,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;"""
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org