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 7de3eeb4fd7 [Chore](function) Improve the code coverage of 
function_json.cpp (#53048)
7de3eeb4fd7 is described below

commit 7de3eeb4fd7fc54f8eaab12ca130d852a178a4a6
Author: Pxl <[email protected]>
AuthorDate: Fri Jul 11 11:41:03 2025 +0800

    [Chore](function) Improve the code coverage of function_json.cpp (#53048)
    
    Improve the code coverage of function_json.cpp
---
 be/src/vec/functions/function_json.cpp             |  12 +++++------
 .../json_functions/test_json_function.out          | Bin 1476 -> 1794 bytes
 .../json_functions/test_json_function.groovy       |  23 ++++++++++++++++++++-
 3 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/be/src/vec/functions/function_json.cpp 
b/be/src/vec/functions/function_json.cpp
index 3e9a3eb570f..5793231c8f4 100644
--- a/be/src/vec/functions/function_json.cpp
+++ b/be/src/vec/functions/function_json.cpp
@@ -1440,19 +1440,17 @@ public:
                         objects[row].GetAllocator());
             }
 
-            switch (Kind::modify_type) {
-            case JsonModifyType::JSON_INSERT:
+            if constexpr (Kind::modify_type == JsonModifyType::JSON_INSERT) {
                 modify_value(*parsed_paths, &objects[row], 
objects[row].GetAllocator(), true, false,
                              &value);
-                break;
-            case JsonModifyType::JSON_REPLACE:
+            }
+            if constexpr (Kind::modify_type == JsonModifyType::JSON_REPLACE) {
                 modify_value(*parsed_paths, &objects[row], 
objects[row].GetAllocator(), false, true,
                              &value);
-                break;
-            case JsonModifyType::JSON_SET:
+            }
+            if constexpr (Kind::modify_type == JsonModifyType::JSON_SET) {
                 modify_value(*parsed_paths, &objects[row], 
objects[row].GetAllocator(), true, true,
                              &value);
-                break;
             }
         }
     }
diff --git 
a/regression-test/data/query_p0/sql_functions/json_functions/test_json_function.out
 
b/regression-test/data/query_p0/sql_functions/json_functions/test_json_function.out
index c22acc17134..145fa7c5010 100644
Binary files 
a/regression-test/data/query_p0/sql_functions/json_functions/test_json_function.out
 and 
b/regression-test/data/query_p0/sql_functions/json_functions/test_json_function.out
 differ
diff --git 
a/regression-test/suites/query_p0/sql_functions/json_functions/test_json_function.groovy
 
b/regression-test/suites/query_p0/sql_functions/json_functions/test_json_function.groovy
index fe4dfc55315..d361198f62d 100644
--- 
a/regression-test/suites/query_p0/sql_functions/json_functions/test_json_function.groovy
+++ 
b/regression-test/suites/query_p0/sql_functions/json_functions/test_json_function.groovy
@@ -91,4 +91,25 @@ suite("test_json_function", "arrow_flight_sql") {
     qt_sql """select get_json_string('{"name\\k" : 123}', '\$.name\\k')"""
     qt_sql """select get_json_string('{"name\\k" : 123}', '\$.name\\\\k')"""
     qt_sql """select get_json_string('{"name\\k" : 123}', '\$.name\\\\\\k')"""
-}
+
+    sql "drop table if exists d_table;"
+    sql """
+        create table d_table (
+            k1 varchar(100) null,
+            k2 varchar(100) not null
+        )
+        duplicate key (k1)
+        distributed BY hash(k1) buckets 3
+        properties("replication_num" = "1");
+    """
+    sql """insert into d_table values 
+    ('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}', '{\"a\": 1, \"b\": 2, \"c\": 
{\"d\": 4}}'),
+    ('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}', '{\"a\": 1, \"b\": 2, \"c\": 
{\"d\": 5}}'),
+    ('{\"a\": 1, \"b\": 2, \"c\": {\"d\": 4}}', '{\"a\": 1, \"b\": 2, \"c\": 
{\"d\": 6}}'),
+    (null,'{\"name\": \"John\", \"age\": 30, \"city\": \"New York\", 
\"hobbies\": [\"reading\", \"travelling\"]}');
+    """
+    qt_test """
+      SELECT k1,k2,JSON_CONTAINS(k1, '\$'),JSON_CONTAINS(k2, '\$') from 
d_table order by k1,k2;
+    """
+
+}
\ No newline at end of file


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

Reply via email to