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

yiguolei 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 669244773d2 [fix](agg) wrong result of two or more map_agg functions 
in query (#31928)
669244773d2 is described below

commit 669244773d2234b7db58ce930ff1957f75631e25
Author: Jerry Hu <mrh...@gmail.com>
AuthorDate: Thu Mar 7 23:58:40 2024 +0800

    [fix](agg) wrong result of two or more map_agg functions in query (#31928)
---
 .../aggregate_functions/aggregate_function_map.h   |  4 +-
 .../data/query_p0/aggregate/map_agg.out            |  3 ++
 .../suites/query_p0/aggregate/map_agg.groovy       | 45 +++++++++++++++++++++-
 3 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_map.h 
b/be/src/vec/aggregate_functions/aggregate_function_map.h
index e0a19a34207..c76f3ee7f7e 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_map.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_map.h
@@ -278,7 +278,7 @@ public:
         auto& col = assert_cast<const ColumnMap&>(*assert_cast<const 
IColumn*>(column));
         for (size_t i = 0; i != num_rows; ++i) {
             auto map = doris::vectorized::get<Map>(col[i]);
-            this->data(places[i]).add(map[0], map[1]);
+            this->data(places[i] + offset).add(map[0], map[1]);
         }
     }
 
@@ -289,7 +289,7 @@ public:
         for (size_t i = 0; i != num_rows; ++i) {
             if (places[i]) {
                 auto map = doris::vectorized::get<Map>(col[i]);
-                this->data(places[i]).add(map[0], map[1]);
+                this->data(places[i] + offset).add(map[0], map[1]);
             }
         }
     }
diff --git a/regression-test/data/query_p0/aggregate/map_agg.out 
b/regression-test/data/query_p0/aggregate/map_agg.out
index 1b349f50a8e..c7db1dcaeae 100644
--- a/regression-test/data/query_p0/aggregate/map_agg.out
+++ b/regression-test/data/query_p0/aggregate/map_agg.out
@@ -40,3 +40,6 @@ V5_3
 002    88.0    90.0    75.5    \N
 003    70.0    85.0    90.0    82.0
 
+-- !multi --
+1      2
+
diff --git a/regression-test/suites/query_p0/aggregate/map_agg.groovy 
b/regression-test/suites/query_p0/aggregate/map_agg.groovy
index 7ca0c543345..351c077df10 100644
--- a/regression-test/suites/query_p0/aggregate/map_agg.groovy
+++ b/regression-test/suites/query_p0/aggregate/map_agg.groovy
@@ -63,7 +63,7 @@ suite("map_agg") {
           ) ENGINE=OLAP
           DUPLICATE KEY(`id`)
           COMMENT 'OLAP'
-          DISTRIBUTED BY HASH(`id`) BUCKETS 2
+          DISTRIBUTED BY HASH(`id`) BUCKETS 10
           PROPERTIES (
           "replication_allocation" = "tag.location.default: 1",
           "storage_format" = "V2",
@@ -279,4 +279,47 @@ suite("map_agg") {
             select userid, map_agg(subject,score) as map from 
test_map_agg_score group by userid
         ) a order by userid;
     """
+
+    sql "DROP TABLE IF EXISTS test_map_agg_multi;"
+    sql """
+        create table test_map_agg_multi (
+            data_time bigint,
+            mil int,
+            vin string,
+            car_type string,
+            month string,
+            day string
+        ) engine=olap
+        distributed by hash(data_time) buckets 10
+        properties("replication_num" = "1");
+    """
+    sql """
+        insert into test_map_agg_multi values (1, 1, 'abc', 'bc', '01', '01'), 
(2, 2, 'abc', 'bc', '01', '01');
+    """
+
+    qt_multi """
+        select
+            m1['1']
+            , m2['2']
+        from (
+            select
+                vin
+                , car_type
+                , map_agg(ts, mile) m1
+                , map_agg(mile, ts) m2
+            from (
+                 select
+                    vin
+                    , car_type
+                    , data_time as ts
+                    , mil as mile, month
+                    , day from test_map_agg_multi
+            )a
+            group by
+               car_type
+               , vin
+               , month
+               , day
+        ) t order by 1, 2;
+    """
  }


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

Reply via email to