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 <happenlee@selectdb.com>
This commit is contained in:
github-actions[bot]
2025-04-06 10:16:11 +08:00
committed by GitHub
parent c0bc16d88f
commit 0ea87fba6f
3 changed files with 13 additions and 6 deletions

View File

@ -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();

View File

@ -155,3 +155,8 @@ true
-- !sql --
\N
-- !sql --
\N \N
false \N
true \N

View File

@ -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; """
}