This is an automated email from the ASF dual-hosted git repository. yiguolei 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 3640f6c2400 [Bug][function] fix the string cast jsonb cause null map have not init value (#49810) 3640f6c2400 is described below commit 3640f6c2400ab818087e00470be72f2f505761bf Author: HappenLee <happen...@selectdb.com> AuthorDate: Sat Apr 5 18:09:36 2025 +0800 [Bug][function] fix the string cast jsonb cause null map have not init value (#49810) ### What problem does this PR solve? Problem Summary: if null map value not init, the value can be random cause the wired bug ``` col_null_map_to = ColumnUInt8::create(size, 0); ``` By the way: maybe we should reconsider the api column create force the init value, but may cause the some performance problem --- be/src/vec/functions/function_cast.h | 12 ++++++------ .../json_functions/test_json_function.out | Bin 1260 -> 1295 bytes .../json_functions/test_json_function.groovy | 2 ++ 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/be/src/vec/functions/function_cast.h b/be/src/vec/functions/function_cast.h index 2701b9aef72..c767740dc63 100644 --- a/be/src/vec/functions/function_cast.h +++ b/be/src/vec/functions/function_cast.h @@ -444,7 +444,7 @@ struct ConvertImpl { // 300 -> 00:03:00 360 will be parse failed , so value maybe null ColumnUInt8::MutablePtr col_null_map_to; ColumnUInt8::Container* vec_null_map_to = nullptr; - col_null_map_to = ColumnUInt8::create(size); + col_null_map_to = ColumnUInt8::create(size, 0); vec_null_map_to = &col_null_map_to->get_data(); for (size_t i = 0; i < size; ++i) { (*vec_null_map_to)[i] = !TimeCast::try_parse_time( @@ -525,7 +525,7 @@ struct ConvertImplToTimeType { // create null column ColumnUInt8::MutablePtr col_null_map_to; - col_null_map_to = ColumnUInt8::create(size); + col_null_map_to = ColumnUInt8::create(size, 0); auto& vec_null_map_to = col_null_map_to->get_data(); if constexpr (std::is_same_v<FromDataType, DataTypeTimeV2>) { @@ -620,7 +620,7 @@ struct ConvertImplGenericFromString { size_t size = col_from.size(); col_to->reserve(size); - ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(size); + ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(size, 0); ColumnUInt8::Container* vec_null_map_to = &col_null_map_to->get_data(); const bool is_complex = is_complex_type(data_type_to); DataTypeSerDe::FormatOptions format_options; @@ -744,7 +744,7 @@ struct ConvertImplGenericFromJsonb { size_t size = col_from.size(); col_to->reserve(size); - ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(size); + ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(size, 0); ColumnUInt8::Container* vec_null_map_to = &col_null_map_to->get_data(); const bool is_complex = is_complex_type(data_type_to); const bool is_dst_string = is_string_or_fixed_string(data_type_to); @@ -824,7 +824,7 @@ struct ConvertImplGenericToJsonb { auto column_string = ColumnString::create(); JsonbWriter writer; - ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(col_from.size()); + ColumnUInt8::MutablePtr col_null_map_to = ColumnUInt8::create(col_from.size(), 0); ColumnUInt8::Container* vec_null_map_to = &col_null_map_to->get_data(); DataTypeSerDe::FormatOptions format_options; format_options.converted_from_string = true; @@ -1412,7 +1412,7 @@ struct StringParsing { ColumnUInt8::MutablePtr col_null_map_to; ColumnUInt8::Container* vec_null_map_to [[maybe_unused]] = nullptr; - col_null_map_to = ColumnUInt8::create(row); + col_null_map_to = ColumnUInt8::create(row, 0); vec_null_map_to = &col_null_map_to->get_data(); const ColumnString::Chars* chars = &col_from_string->get_chars(); 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 bd14394d375..45d1d1b9e03 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 4bd88bf131e..20ef0843e39 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 @@ -77,4 +77,6 @@ suite("test_json_function", "arrow_flight_sql") { qt_sql """SELECT JSON_CONTAINS('','1','\$.a')""" qt_sql """SELECT JSON_CONTAINS('""','1','\$.a')""" qt_sql """SELECT JSON_CONTAINS("",'1','\$.a')""" + + qt_sql """select k6, json_extract_string(cast(k7 as json), "\$.a") as x10 from test_query_db.baseall group by k6, x10 order by 1,2; """ } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org