[Bug] [Bitmap] change to_bitmap to always_not_nullable (#9716)
This commit is contained in:
@ -1102,8 +1102,9 @@ Status OlapTableSink::_convert_batch(RuntimeState* state, RowBatch* input_batch,
|
||||
[]() -> std::string { return ""; },
|
||||
[&]() -> std::string {
|
||||
fmt::memory_buffer buf;
|
||||
fmt::format_to(buf, "null value for not null column, column={}",
|
||||
slot_desc->col_name());
|
||||
fmt::format_to(
|
||||
buf, "null value for not null column, column={}, type={}",
|
||||
slot_desc->col_name(), slot_desc->type().debug_string());
|
||||
return fmt::to_string(buf);
|
||||
},
|
||||
&stop_processing));
|
||||
|
||||
@ -366,17 +366,17 @@ BigIntVal BitmapFunctions::bitmap_min(FunctionContext* ctx, const StringVal& src
|
||||
|
||||
StringVal BitmapFunctions::to_bitmap(doris_udf::FunctionContext* ctx,
|
||||
const doris_udf::StringVal& src) {
|
||||
if (src.is_null) {
|
||||
return StringVal::null();
|
||||
}
|
||||
StringParser::ParseResult parse_result = StringParser::PARSE_SUCCESS;
|
||||
uint64_t int_value = StringParser::string_to_unsigned_int<uint64_t>(
|
||||
reinterpret_cast<char*>(src.ptr), src.len, &parse_result);
|
||||
if (UNLIKELY(parse_result != StringParser::PARSE_SUCCESS)) {
|
||||
return StringVal::null();
|
||||
}
|
||||
BitmapValue bitmap;
|
||||
bitmap.add(int_value);
|
||||
|
||||
if (!src.is_null) {
|
||||
StringParser::ParseResult parse_result = StringParser::PARSE_SUCCESS;
|
||||
uint64_t int_value = StringParser::string_to_unsigned_int<uint64_t>(
|
||||
reinterpret_cast<char*>(src.ptr), src.len, &parse_result);
|
||||
if (parse_result == StringParser::PARSE_SUCCESS) {
|
||||
bitmap.add(int_value);
|
||||
}
|
||||
}
|
||||
|
||||
return serialize(ctx, &bitmap);
|
||||
}
|
||||
|
||||
|
||||
@ -45,18 +45,16 @@ struct ToBitmap {
|
||||
auto size = offsets.size();
|
||||
res.reserve(size);
|
||||
for (size_t i = 0; i < size; ++i) {
|
||||
res.emplace_back();
|
||||
|
||||
const char* raw_str = reinterpret_cast<const char*>(&data[offsets[i - 1]]);
|
||||
size_t str_size = offsets[i] - offsets[i - 1] - 1;
|
||||
StringParser::ParseResult parse_result = StringParser::PARSE_SUCCESS;
|
||||
uint64_t int_value = StringParser::string_to_unsigned_int<uint64_t>(raw_str, str_size,
|
||||
&parse_result);
|
||||
if (UNLIKELY(parse_result != StringParser::PARSE_SUCCESS)) {
|
||||
res.emplace_back();
|
||||
null_map[i] = 1;
|
||||
continue;
|
||||
if (LIKELY(parse_result == StringParser::PARSE_SUCCESS)) {
|
||||
res.back().add(int_value);
|
||||
}
|
||||
res.emplace_back();
|
||||
res.back().add(int_value);
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
@ -86,19 +86,19 @@ TEST_F(BitmapFunctionsTest, to_bitmap_null) {
|
||||
StringVal input = StringVal::null();
|
||||
StringVal result = BitmapFunctions::to_bitmap(ctx, input);
|
||||
|
||||
EXPECT_EQ(StringVal::null(), result);
|
||||
EXPECT_EQ(BitmapFunctions::bitmap_empty(ctx), result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, to_bitmap_invalid_argument) {
|
||||
StringVal input = AnyValUtil::from_string_temp(ctx, std::string("-1"));
|
||||
StringVal result = BitmapFunctions::to_bitmap(ctx, input);
|
||||
EXPECT_EQ(StringVal::null(), result);
|
||||
EXPECT_EQ(BitmapFunctions::bitmap_empty(ctx), result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, to_bitmap_out_of_range) {
|
||||
StringVal input = AnyValUtil::from_string_temp(ctx, std::string("18446744073709551616"));
|
||||
StringVal result = BitmapFunctions::to_bitmap(ctx, input);
|
||||
EXPECT_EQ(StringVal::null(), result);
|
||||
EXPECT_EQ(BitmapFunctions::bitmap_empty(ctx), result);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_union_int) {
|
||||
|
||||
@ -1175,13 +1175,13 @@ visible_functions = [
|
||||
|
||||
[['to_bitmap'], 'BITMAP', ['VARCHAR'],
|
||||
'_ZN5doris15BitmapFunctions9to_bitmapEPN9doris_udf15FunctionContextERKNS1_9StringValE',
|
||||
'', '', 'vec', 'ALWAYS_NULLABLE'],
|
||||
'', '', 'vec', 'ALWAYS_NOT_NULLABLE'],
|
||||
[['bitmap_hash'], 'BITMAP', ['VARCHAR'],
|
||||
'_ZN5doris15BitmapFunctions11bitmap_hashEPN9doris_udf15FunctionContextERKNS1_9StringValE',
|
||||
'', '', 'vec', 'ALWAYS_NOT_NULLABLE'],
|
||||
[['to_bitmap'], 'BITMAP', ['STRING'],
|
||||
'_ZN5doris15BitmapFunctions9to_bitmapEPN9doris_udf15FunctionContextERKNS1_9StringValE',
|
||||
'', '', 'vec', 'ALWAYS_NULLABLE'],
|
||||
'', '', 'vec', 'ALWAYS_NOT_NULLABLE'],
|
||||
[['bitmap_hash'], 'BITMAP', ['STRING'],
|
||||
'_ZN5doris15BitmapFunctions11bitmap_hashEPN9doris_udf15FunctionContextERKNS1_9StringValE',
|
||||
'', '', 'vec', 'ALWAYS_NOT_NULLABLE'],
|
||||
|
||||
Reference in New Issue
Block a user