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 2025/10/16 01:52:05 UTC

(doris) branch branch-4.0 updated: branch-4.0: [fix](function) Crash caused by explode function #56991 (#57000)

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

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


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 3032868640d branch-4.0: [fix](function) Crash caused by explode function #56991 (#57000)
3032868640d is described below

commit 3032868640d91be5148a7131463176ef26bd99d6
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Thu Oct 16 09:51:58 2025 +0800

    branch-4.0: [fix](function) Crash caused by explode function #56991 (#57000)
    
    Cherry-picked from #56991
    
    Co-authored-by: Jerry Hu <hu...@selectdb.com>
---
 be/src/vec/exprs/table_function/vexplode_v2.cpp    |  4 +-
 .../sql_functions/table_function/explode.out       | 72 ++++++++++++++++++++++
 .../sql_functions/table_function/explode.groovy    | 25 ++++++++
 3 files changed, 100 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/exprs/table_function/vexplode_v2.cpp b/be/src/vec/exprs/table_function/vexplode_v2.cpp
index 1a40bc1feda..47a4f41147b 100644
--- a/be/src/vec/exprs/table_function/vexplode_v2.cpp
+++ b/be/src/vec/exprs/table_function/vexplode_v2.cpp
@@ -228,7 +228,7 @@ int VExplodeV2TableFunction::get_value(MutableColumnPtr& column, int max_step) {
                     } else {
                         nullmap_column->insert_many_defaults(max_step);
                     }
-                } else {
+                } else if (element_size > _cur_offset) {
                     auto current_insert_num = element_size - _cur_offset;
                     nullable_column->get_nested_column_ptr()->insert_range_from(
                             *detail.nested_col, pos, current_insert_num);
@@ -242,6 +242,8 @@ int VExplodeV2TableFunction::get_value(MutableColumnPtr& column, int max_step) {
                         nullmap_column->insert_many_defaults(current_insert_num);
                     }
                     nullable_column->insert_many_defaults(max_step - current_insert_num);
+                } else {
+                    nullable_column->insert_many_defaults(max_step);
                 }
             }
         }
diff --git a/regression-test/data/query_p0/sql_functions/table_function/explode.out b/regression-test/data/query_p0/sql_functions/table_function/explode.out
index 234119bea63..1a6280bb84f 100644
--- a/regression-test/data/query_p0/sql_functions/table_function/explode.out
+++ b/regression-test/data/query_p0/sql_functions/table_function/explode.out
@@ -675,3 +675,75 @@
 3	116	\N	115	\N
 3	116	\N	116	\N
 
+-- !test24 --
+a	\N	\N	\N	4
+a	\N	\N	\N	5
+a	\N	\N	ef	1
+a	\N	1	ab	\N
+a	\N	2	cd	\N
+a	\N	4	\N	2
+a	\N	5	\N	3
+b	\N	\N	\N	4
+b	\N	\N	\N	5
+b	\N	\N	ef	1
+b	\N	1	ab	\N
+b	\N	2	cd	\N
+b	\N	4	\N	2
+b	\N	5	\N	3
+c	\N	\N	\N	4
+c	\N	\N	\N	5
+c	\N	\N	ef	1
+c	\N	1	ab	\N
+c	\N	2	cd	\N
+c	\N	4	\N	2
+c	\N	5	\N	3
+d	\N	\N	\N	4
+d	\N	\N	\N	5
+d	\N	\N	ef	1
+d	\N	1	ab	\N
+d	\N	2	cd	\N
+d	\N	4	\N	2
+d	\N	5	\N	3
+e	\N	\N	\N	4
+e	\N	\N	\N	5
+e	\N	\N	ef	1
+e	\N	1	ab	\N
+e	\N	2	cd	\N
+e	\N	4	\N	2
+e	\N	5	\N	3
+f	\N	\N	\N	4
+f	\N	\N	\N	5
+f	\N	\N	ef	1
+f	\N	1	ab	\N
+f	\N	2	cd	\N
+f	\N	4	\N	2
+f	\N	5	\N	3
+g	\N	\N	\N	4
+g	\N	\N	\N	5
+g	\N	\N	ef	1
+g	\N	1	ab	\N
+g	\N	2	cd	\N
+g	\N	4	\N	2
+g	\N	5	\N	3
+h	\N	\N	\N	4
+h	\N	\N	\N	5
+h	\N	\N	ef	1
+h	\N	1	ab	\N
+h	\N	2	cd	\N
+h	\N	4	\N	2
+h	\N	5	\N	3
+i	\N	\N	\N	4
+i	\N	\N	\N	5
+i	\N	\N	ef	1
+i	\N	1	ab	\N
+i	\N	2	cd	\N
+i	\N	4	\N	2
+i	\N	5	\N	3
+j	\N	\N	\N	4
+j	\N	\N	\N	5
+j	\N	\N	ef	1
+j	\N	1	ab	\N
+j	\N	2	cd	\N
+j	\N	4	\N	2
+j	\N	5	\N	3
+
diff --git a/regression-test/suites/query_p0/sql_functions/table_function/explode.groovy b/regression-test/suites/query_p0/sql_functions/table_function/explode.groovy
index 3ec71810eaa..fb1a9e29e09 100644
--- a/regression-test/suites/query_p0/sql_functions/table_function/explode.groovy
+++ b/regression-test/suites/query_p0/sql_functions/table_function/explode.groovy
@@ -188,4 +188,29 @@ suite("explode") {
     qt_test22 "select id,e1,e2,e3 from array_test as a lateral view explode_variant_array(a.v_string['a'],a.v_int['a'],a.v_int['a']) tmp1 as e1,e2,e3;"
     qt_test23 "select id,e1,e2,e11,e12 from array_test as a lateral view explode_variant_array(a.v_int['a'],a.v_string['a']) tmp1 as e1,e2 lateral view explode_variant_array(a.v_int['a'],a.v_string['a']) tmp2 as e11,e12;"
 
+    sql "DROP TABLE IF EXISTS array_test2;"
+    sql """
+        CREATE TABLE `array_test2` (
+        `v` varchar(10)
+        ) DISTRIBUTED BY RANDOM BUCKETS 1
+        PROPERTIES (
+        "replication_allocation" = "tag.location.default: 1"
+        );
+    """
+
+    sql """
+        insert into array_test2 values
+            ("a"), ("b"), ("c"), ("d"), ("e"),
+            ("f"), ("g"), ("h"), ("i"), ("j");
+    """
+
+    sql "set batch_size = 16"
+
+    qt_test24 """
+        select
+            *
+        from array_test2 
+        lateral view explode([], [1, 2, null, 4, 5], ["ab", "cd", "ef"], [null, null, 1, 2, 3, 4, 5]) t2 as c0, c1, c2, c3 
+        order by 1,2,3,4,5;
+    """
 }


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