You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/06/01 15:29:00 UTC
[incubator-doris] 05/22: [Bug] [Bitmap] change to_bitmap to always_not_nullable (#9716)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch dev-1.0.1
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git
commit 0224db0417f06afc843c83abeb61aacd63bd59bc
Author: Pxl <px...@qq.com>
AuthorDate: Sat May 28 17:33:55 2022 +0800
[Bug] [Bitmap] change to_bitmap to always_not_nullable (#9716)
---
be/src/exec/tablet_sink.cpp | 5 +++--
be/src/exprs/bitmap_function.cpp | 20 ++++++++++----------
be/src/vec/functions/function_bitmap.cpp | 10 ++++------
be/test/exprs/bitmap_function_test.cpp | 6 +++---
gensrc/script/doris_builtins_functions.py | 4 ++--
5 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/be/src/exec/tablet_sink.cpp b/be/src/exec/tablet_sink.cpp
index 5604483012..f40d1b0211 100644
--- a/be/src/exec/tablet_sink.cpp
+++ b/be/src/exec/tablet_sink.cpp
@@ -1134,8 +1134,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));
diff --git a/be/src/exprs/bitmap_function.cpp b/be/src/exprs/bitmap_function.cpp
index ed9c7b2825..d49863ab73 100644
--- a/be/src/exprs/bitmap_function.cpp
+++ b/be/src/exprs/bitmap_function.cpp
@@ -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);
}
diff --git a/be/src/vec/functions/function_bitmap.cpp b/be/src/vec/functions/function_bitmap.cpp
index 614289e072..0b80c88b5d 100644
--- a/be/src/vec/functions/function_bitmap.cpp
+++ b/be/src/vec/functions/function_bitmap.cpp
@@ -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();
}
diff --git a/be/test/exprs/bitmap_function_test.cpp b/be/test/exprs/bitmap_function_test.cpp
index cffc9d71b2..334ba7aa73 100644
--- a/be/test/exprs/bitmap_function_test.cpp
+++ b/be/test/exprs/bitmap_function_test.cpp
@@ -86,19 +86,19 @@ TEST_F(BitmapFunctionsTest, to_bitmap_null) {
StringVal input = StringVal::null();
StringVal result = BitmapFunctions::to_bitmap(ctx, input);
- ASSERT_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);
- ASSERT_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);
- ASSERT_EQ(StringVal::null(), result);
+ EXPECT_EQ(BitmapFunctions::bitmap_empty(ctx), result);
}
TEST_F(BitmapFunctionsTest, bitmap_union_int) {
diff --git a/gensrc/script/doris_builtins_functions.py b/gensrc/script/doris_builtins_functions.py
index 8e8797430e..4655856624 100755
--- a/gensrc/script/doris_builtins_functions.py
+++ b/gensrc/script/doris_builtins_functions.py
@@ -1137,13 +1137,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'],
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org