xinyiZzz commented on a change in pull request #6917: URL: https://github.com/apache/incubator-doris/pull/6917#discussion_r739937010
########## File path: be/test/exprs/bitmap_function_test.cpp ########## @@ -552,6 +552,67 @@ TEST_F(BitmapFunctionsTest, bitmap_max) { ASSERT_EQ(BigIntVal(1024), result); } +TEST_F(BitmapFunctionsTest, bitmap_subset_in_range) { + // null + StringVal res = BitmapFunctions::bitmap_subset_in_range(ctx, StringVal::null(), BigIntVal(1), BigIntVal(3)); + ASSERT_TRUE(res.is_null); + + // empty + BitmapValue bitmap0; + StringVal empty_str = convert_bitmap_to_string(ctx, bitmap0); + res = BitmapFunctions::bitmap_subset_in_range(ctx, empty_str, BigIntVal(1), BigIntVal(3)); + BigIntVal result = BitmapFunctions::bitmap_count(ctx, res); + ASSERT_EQ(BigIntVal(0), result); + + // normal + BitmapValue bitmap1({0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,208,23,24,25,26,27,28,29,30,31,32,33,100,200,500}); + + StringVal bitmap_src = convert_bitmap_to_string(ctx, bitmap1); + res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(30), BigIntVal(200)); + result = BitmapFunctions::bitmap_count(ctx, res); + ASSERT_EQ(BigIntVal(5), result); + + res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(0), BigIntVal(1)); + result = BitmapFunctions::bitmap_count(ctx, res); + ASSERT_EQ(BigIntVal(1), result); + + res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(11), BigIntVal(15)); + result = BitmapFunctions::bitmap_count(ctx, res); + ASSERT_EQ(BigIntVal(4), result); + + res = BitmapFunctions::bitmap_subset_in_range(ctx, bitmap_src, BigIntVal(11), DecimalV2Value::MAX_INT64); Review comment: It seems to be better to use BigIntVal(INT64_MAX) and BigIntVal(INT64_MIN) here -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org