You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/04/21 06:05:07 UTC

[doris] 06/08: [Bug](table-function) fix wrong result when seprator of explode_split size more than one (#18824)

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

morningman pushed a commit to branch branch-2.0-alpha
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 95c4b53c4e2600f207d6c95506a89f6194ccdf5a
Author: Pxl <px...@qq.com>
AuthorDate: Fri Apr 21 11:00:47 2023 +0800

    [Bug](table-function) fix wrong result when seprator of explode_split size more than one (#18824)
    
    fix wrong result when seprator of explode_split size more than one
---
 be/src/vec/exprs/table_function/vexplode_split.cpp                  | 3 +--
 .../data/nereids_p0/sql_functions/table_function/explode_split.out  | 6 ++++++
 .../nereids_p0/sql_functions/table_function/explode_split.groovy    | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/be/src/vec/exprs/table_function/vexplode_split.cpp b/be/src/vec/exprs/table_function/vexplode_split.cpp
index d2438d8c9a..abc9b9a42b 100644
--- a/be/src/vec/exprs/table_function/vexplode_split.cpp
+++ b/be/src/vec/exprs/table_function/vexplode_split.cpp
@@ -84,11 +84,10 @@ Status VExplodeSplitTableFunction::process_row(size_t row_idx) {
                 if (first != second) {
                     output.emplace_back(strv.substr(std::distance(strv.begin(), first),
                                                     std::distance(first, second)));
-                    first = std::next(second);
                 } else {
                     output.emplace_back("", 0);
-                    first = std::next(second, delims.size());
                 }
+                first = std::next(second, delims.size());
 
                 if (second == last) {
                     break;
diff --git a/regression-test/data/nereids_p0/sql_functions/table_function/explode_split.out b/regression-test/data/nereids_p0/sql_functions/table_function/explode_split.out
index a723f46dab..a430812264 100644
--- a/regression-test/data/nereids_p0/sql_functions/table_function/explode_split.out
+++ b/regression-test/data/nereids_p0/sql_functions/table_function/explode_split.out
@@ -20,3 +20,9 @@
 6	b
 6	c
 
+-- !explode_split --
+啊
+啊
+额
+啊
+
diff --git a/regression-test/suites/nereids_p0/sql_functions/table_function/explode_split.groovy b/regression-test/suites/nereids_p0/sql_functions/table_function/explode_split.groovy
index c28f43c4b3..9f64864be7 100644
--- a/regression-test/suites/nereids_p0/sql_functions/table_function/explode_split.groovy
+++ b/regression-test/suites/nereids_p0/sql_functions/table_function/explode_split.groovy
@@ -41,4 +41,5 @@ suite("explode_split") {
                          select  k1, e1 from example1
                          lateral view explode_split(k2, ',') tmp as  e1 """
 
+    qt_explode_split """ select e1 from (select 1 k1) as t lateral view explode_split("啊,啊,额,啊",",") tmp1 as e1; """
 }


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