This is an automated email from the ASF dual-hosted git repository.
zhangstar333 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 3f86819154a [Bug](function)fix json_object function check null nums
error as return bool (#44321)
3f86819154a is described below
commit 3f86819154a0ec03fc2386d831e8701575de8cd7
Author: zhangstar333 <[email protected]>
AuthorDate: Thu Nov 21 14:02:40 2024 +0800
[Bug](function)fix json_object function check null nums error as return
bool (#44321)
### What problem does this PR solve?
Related PR: #https://github.com/apache/doris/pull/34591/files
Problem Summary:
before the SQL report error, as it error change the simd::count_zero_num
function return value static as bool,
so it run into the if check of (not_null_num < size).
but actual it's maybe return int type.
now:
```
mysql [(none)]>select json_object ( CONCAT('k',t.number%30926%3000 +
0),CONCAT('k',t.number%30926%3000 + 0,t.number%1000000) ) from numbers("number"
= "2") t order by 1;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| json_object(concat('k', cast((((number % 30926) % 3000) + 0) as
VARCHAR(65533))), concat('k', cast((((number % 30926) % 3000) + 0) as
VARCHAR(65533)), cast((number % 1000000) as VARCHAR(65533))), '66') |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {"k0":"k00"}
|
| {"k1":"k11"}
|
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.04 sec)
```
before:
```
mysql [(none)]>select json_object
-> (
-> CONCAT('k',t.number%30926%3000 + 0),CONCAT('k',t.number%30926%3000 +
0,t.number%1000000)
-> )
-> from numbers("number" = "2") t;
ERROR 1105 (HY000): errCode = 2, detailMessage =
(10.16.10.8)[INTERNAL_ERROR]function json_object can not input null value ,
JSON documents may not contain NULL member names.
mysql [(none)]>
```
---
be/src/vec/functions/function_json.cpp | 6 +++---
.../query_p0/sql_functions/json_function/test_query_json_object.out | 4 ++++
.../sql_functions/json_function/test_query_json_object.groovy | 2 ++
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/be/src/vec/functions/function_json.cpp
b/be/src/vec/functions/function_json.cpp
index 6ab03dbbb7b..c53b31d7ec6 100644
--- a/be/src/vec/functions/function_json.cpp
+++ b/be/src/vec/functions/function_json.cpp
@@ -788,13 +788,13 @@ public:
for (int i = 0; i < args; i += 2) {
const auto* null_map = nullmaps[i];
if (null_map) {
- const bool not_null_num =
+ auto not_null_num =
simd::count_zero_num((int8_t*)null_map->get_data().data(), size);
if (not_null_num < size) {
return Status::InternalError(
"function {} can not input null value , JSON
documents may not contain "
- "NULL member names.",
- name);
+ "NULL member names. input size is {}:{}",
+ name, size, not_null_num);
}
}
}
diff --git
a/regression-test/data/query_p0/sql_functions/json_function/test_query_json_object.out
b/regression-test/data/query_p0/sql_functions/json_function/test_query_json_object.out
index 6dc88471573..13d30f6e75e 100644
---
a/regression-test/data/query_p0/sql_functions/json_function/test_query_json_object.out
+++
b/regression-test/data/query_p0/sql_functions/json_function/test_query_json_object.out
@@ -6,3 +6,7 @@
{"k0":4,"k1":null,"k2":null,"k3":"test","k4":"2022-01-01
11:11:11","k5":null,"k6":"k6"}
{"k0":5,"k1":1,"k2":true,"k3":"test","k4":"2022-01-01
11:11:11","k5":null,"k6":"k6"}
+-- !sql2 --
+{"k0":"k00"}
+{"k1":"k11"}
+
diff --git
a/regression-test/suites/query_p0/sql_functions/json_function/test_query_json_object.groovy
b/regression-test/suites/query_p0/sql_functions/json_function/test_query_json_object.groovy
index c3b1e35b5e6..2ee0c64276c 100644
---
a/regression-test/suites/query_p0/sql_functions/json_function/test_query_json_object.groovy
+++
b/regression-test/suites/query_p0/sql_functions/json_function/test_query_json_object.groovy
@@ -45,5 +45,7 @@ suite("test_query_json_object", "query") {
sql """select k0,json_object(k3,123) from ${tableName} order by k0;"""
exception "function json_object can not input null value , JSON
documents may not contain NULL member names."
}
+
+ qt_sql2 """select json_object ( CONCAT('k',t.number%30926%3000 +
0),CONCAT('k',t.number%30926%3000 + 0,t.number%1000000) ) from numbers("number"
= "2") t order by 1;"""
sql "DROP TABLE ${tableName};"
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]