You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2023/04/03 10:10:59 UTC

[doris] branch branch-1.2-lts updated: [fix](grouping) fix coredump of grouping function for outer join (#18345)

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

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

commit 20ce60c32664506845eba0e8471d4a567c5a77d9
Author: TengJianPing <18...@users.noreply.github.com>
AuthorDate: Mon Apr 3 18:10:52 2023 +0800

    [fix](grouping) fix coredump of grouping function for outer join (#18345)
---
 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: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org