This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 0ea87fba6f0 branch-2.1: [Bug][function] fix the string cast jsonb cause null map have not init value #49810 (#49817) 0ea87fba6f0 is described below commit 0ea87fba6f04c423c752475bfffadddbebeecce4 Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Sun Apr 6 10:16:11 2025 +0800 branch-2.1: [Bug][function] fix the string cast jsonb cause null map have not init value #49810 (#49817) Cherry-picked from #49810 Co-authored-by: HappenLee <happen...@selectdb.com> --- 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 cf3ea7b0791..5df75b05a54 100644 --- a/be/src/vec/functions/function_cast.h +++ b/be/src/vec/functions/function_cast.h @@ -442,7 +442,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( @@ -513,7 +513,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(); UInt32 from_precision = 0; @@ -591,7 +591,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; @@ -708,7 +708,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); @@ -788,7 +788,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; @@ -1539,7 +1539,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