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 7cd8f7c9ba [fix](grouping) fix coredump of grouping function for outer 
join (#18292)
7cd8f7c9ba is described below

commit 7cd8f7c9bab434bcec46d4c55a315196413f40e1
Author: TengJianPing <[email protected]>
AuthorDate: Mon Apr 3 09:35:31 2023 +0800

    [fix](grouping) fix coredump of grouping function for outer join (#18292)
    
    Result of functions grouping and grouping_id is always not nullable, but 
outer join will convert the result column to nullable when necessary, which 
will cause mismatch of column type and column object when executing unctions 
grouping and grouping_id.
---
 be/src/vec/functions/function_grouping.h           |  5 +-
 .../query_p0/grouping_sets/test_grouping_sets1.out |  5 ++
 .../grouping_sets/test_grouping_sets1.groovy       | 84 ++++++++++++++++++++++
 3 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/functions/function_grouping.h 
b/be/src/vec/functions/function_grouping.h
index 17aa1fdfe6..ae96a50a76 100644
--- a/be/src/vec/functions/function_grouping.h
+++ b/be/src/vec/functions/function_grouping.h
@@ -38,7 +38,10 @@ public:
                         size_t result, size_t input_rows_count) override {
         const ColumnWithTypeAndName& src_column = 
block.get_by_position(arguments[0]);
         DCHECK(src_column.column->size() == input_rows_count);
-        block.get_by_position(result).column = src_column.column;
+        // result of functions grouping and grouping_id is always not nullable,
+        // but outer join will convert the column to nullable when necessary,
+        // so need to remove nullable here when functions grouping and 
grouping_id are executed
+        block.get_by_position(result).column = 
remove_nullable(src_column.column);
         return Status::OK();
     }
 };
diff --git 
a/regression-test/data/query_p0/grouping_sets/test_grouping_sets1.out 
b/regression-test/data/query_p0/grouping_sets/test_grouping_sets1.out
index a717f57bf4..31973c7bb9 100644
--- a/regression-test/data/query_p0/grouping_sets/test_grouping_sets1.out
+++ b/regression-test/data/query_p0/grouping_sets/test_grouping_sets1.out
@@ -29,3 +29,8 @@ a     \N      a       -1      0       0       0       0       
0       1
 a      \N      a       -1      0       1       0       1       1       1
 \N     \N      all     -1      1       1       1       1       3       2
 
+-- !sql_grouping_nullable --
+2019-05-04     2019-05-04      2019-05-04      2019-05-04
+2019-05-05     2019-05-05      2019-05-05      2019-05-05
+\N     empty   \N      empty
+
diff --git 
a/regression-test/suites/query_p0/grouping_sets/test_grouping_sets1.groovy 
b/regression-test/suites/query_p0/grouping_sets/test_grouping_sets1.groovy
index 477f607a76..e3808f55f0 100644
--- a/regression-test/suites/query_p0/grouping_sets/test_grouping_sets1.groovy
+++ b/regression-test/suites/query_p0/grouping_sets/test_grouping_sets1.groovy
@@ -109,4 +109,88 @@ suite("test_grouping_sets1") {
             grouping_col1,grouping_col2,col1,col2 
         ;
     """
+
+
+    sql """ DROP TABLE IF EXISTS `grouping_t1`; """
+    sql """
+        CREATE TABLE `grouping_t1` (
+          `p_date` date NULL,
+          `entry_id` varchar(200) NULL,
+          `publish_date` text NULL
+        ) ENGINE=OLAP
+        UNIQUE KEY(`p_date`, `entry_id`)
+        COMMENT 'OLAP'
+        DISTRIBUTED BY HASH(`entry_id`) BUCKETS 1
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+    
+    sql """
+        insert into grouping_t1 values ("2023-03-29", "aaa", "2019-05-04"),
+                                       ("2023-03-29", "bbb", "2019-05-04"),
+                                       ("2023-03-30", "aaa", "2019-05-05");
+    """
+    
+    sql """ DROP TABLE IF EXISTS `grouping_t2`; """
+    sql """
+        CREATE TABLE `grouping_t2` (
+          `p_date` date NULL,
+          `entry_id` varchar(64) NULL,
+          `entry_date` varchar(64) NULL
+        ) ENGINE=OLAP
+        DUPLICATE KEY(`p_date`, `entry_id`)
+        DISTRIBUTED BY HASH(`entry_id`) BUCKETS 2
+        PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+    
+    sql """
+        insert into grouping_t2 values ("2023-03-29", "aaa", "2019-05-04"),
+                                       ("2023-03-29", "bbb", "2019-05-04"),
+                                       ("2023-03-30", "aaa", "2019-05-05");
+    """
+
+    qt_sql_grouping_nullable """
+        select
+         *
+        from
+          (
+            select
+              idt_335.publish_date,
+              if(
+                grouping(idt_335.publish_date) = 0,
+                idt_335.publish_date,
+                'empty'
+              ) as dim_207
+            from
+              (
+                select
+                  *
+                from
+                  grouping_t1
+              ) idt_335
+            group by
+              GROUPING SETS((idt_335.publish_date),())
+          ) t_0 full
+          join (
+            select
+              idt_765.entry_date,
+              if(
+                grouping(idt_765.entry_date) = 0,
+                idt_765.entry_date,
+                'empty'
+              ) as dim_207
+            from
+              (
+                select
+                  *
+                from
+                  grouping_t2
+              ) idt_765
+            group by
+              GROUPING SETS((idt_765.entry_date),())
+          ) t_1 on t_0.dim_207 = t_1.dim_207;
+    """
 }


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

Reply via email to