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

panxiaolei 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 292ccaeda85 insert default when json array parse failed (#25447)
292ccaeda85 is described below

commit 292ccaeda8578ec34786f91f0c119ea85fc12d9d
Author: Pxl <pxl...@qq.com>
AuthorDate: Mon Oct 16 14:51:26 2023 +0800

    insert default when json array parse failed (#25447)
    
    insert default when json array parse failed
---
 be/src/vec/exprs/table_function/vexplode_json_array.cpp              | 2 +-
 .../query_p0/sql_functions/table_function/explode_json_array.out     | 4 ++++
 .../query_p0/sql_functions/table_function/explode_json_array.groovy  | 5 +++++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/exprs/table_function/vexplode_json_array.cpp 
b/be/src/vec/exprs/table_function/vexplode_json_array.cpp
index 464cdecca4a..811d34ccdec 100644
--- a/be/src/vec/exprs/table_function/vexplode_json_array.cpp
+++ b/be/src/vec/exprs/table_function/vexplode_json_array.cpp
@@ -215,7 +215,7 @@ Status VExplodeJsonArrayTableFunction::process_close() {
 }
 
 void VExplodeJsonArrayTableFunction::get_value(MutableColumnPtr& column) {
-    if (current_empty()) {
+    if (current_empty() || _parsed_data.get_value(_type, _cur_offset, true) == 
nullptr) {
         column->insert_default();
     } else {
         column->insert_data((char*)_parsed_data.get_value(_type, _cur_offset, 
true),
diff --git 
a/regression-test/data/query_p0/sql_functions/table_function/explode_json_array.out
 
b/regression-test/data/query_p0/sql_functions/table_function/explode_json_array.out
index d66887925ab..2300079d0a8 100644
--- 
a/regression-test/data/query_p0/sql_functions/table_function/explode_json_array.out
+++ 
b/regression-test/data/query_p0/sql_functions/table_function/explode_json_array.out
@@ -21,6 +21,10 @@
 30     8
 60     8
 
+-- !explode_json_array_8_invalid --
+0      8
+60     8
+
 -- !explode_json_array9 --
 
 -- !explode_json_array10 --
diff --git 
a/regression-test/suites/query_p0/sql_functions/table_function/explode_json_array.groovy
 
b/regression-test/suites/query_p0/sql_functions/table_function/explode_json_array.groovy
index 7bc3dac1d62..cd4e018243e 100644
--- 
a/regression-test/suites/query_p0/sql_functions/table_function/explode_json_array.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/table_function/explode_json_array.groovy
@@ -45,6 +45,11 @@ suite("explode_json_array") {
                         LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[40, 80]') t2 as 
d_age 
                         GROUP BY c_age ORDER BY c_age """
 
+    qt_explode_json_array_8_invalid """ SELECT c_age, COUNT(1) FROM 
${tableName}
+                        LATERAL VIEW EXPLODE_JSON_ARRAY_INT('["1", 60]') t1 as 
c_age 
+                        LATERAL VIEW EXPLODE_JSON_ARRAY_INT('["b", "c"]') t2 
as d_age 
+                        GROUP BY c_age ORDER BY c_age """
+
     qt_explode_json_array9 """ SELECT * FROM ${tableName}
                             LATERAL VIEW EXPLODE_JSON_ARRAY_INT('[]') t1 AS 
c_age 
                             ORDER BY id, c_age """


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

Reply via email to