[Function] add bitmap function of bitmap_has_all (#6918)
The 'bitmap_has_all' function returns true if the first bitmap contains all the elements of the second bitmap.
This commit is contained in:
@ -504,6 +504,41 @@ TEST_F(BitmapFunctionsTest, bitmap_has_any) {
|
||||
ASSERT_EQ(expected2, result1);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_has_all) {
|
||||
BitmapValue bitmap1({1, 4, 5, std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()});
|
||||
BitmapValue bitmap2({4, std::numeric_limits<uint64_t>::max(), std::numeric_limits<uint64_t>::min()});
|
||||
StringVal string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
StringVal string_val2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
BooleanVal result = BitmapFunctions::bitmap_has_all(ctx, string_val1, string_val2);
|
||||
ASSERT_EQ(BooleanVal{true}, result);
|
||||
|
||||
bitmap1 = BitmapValue({0, 1, 2});
|
||||
bitmap2 = BitmapValue({0, 1, 2, std::numeric_limits<uint64_t>::max()});
|
||||
string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
string_val2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_has_all(ctx, string_val1, string_val2);
|
||||
ASSERT_EQ(BooleanVal{false}, result);
|
||||
|
||||
bitmap1 = BitmapValue();
|
||||
bitmap2 = BitmapValue({0, 1, 2});
|
||||
string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
string_val2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_has_all(ctx, string_val1, string_val2);
|
||||
ASSERT_EQ(BooleanVal{false}, result);
|
||||
|
||||
bitmap1 = BitmapValue();
|
||||
bitmap2 = BitmapValue();
|
||||
string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
string_val2 = convert_bitmap_to_string(ctx, bitmap2);
|
||||
result = BitmapFunctions::bitmap_has_all(ctx, string_val1, string_val2);
|
||||
ASSERT_EQ(BooleanVal{true}, result);
|
||||
|
||||
bitmap1 = BitmapValue();
|
||||
string_val1 = convert_bitmap_to_string(ctx, bitmap1);
|
||||
result = BitmapFunctions::bitmap_has_all(ctx, string_val1, StringVal::null());
|
||||
ASSERT_TRUE(result.is_null);
|
||||
}
|
||||
|
||||
TEST_F(BitmapFunctionsTest, bitmap_from_string) {
|
||||
FunctionUtils utils;
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user