diff --git a/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h b/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h index f98c8772752..734a63fd755 100644 --- a/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h +++ b/src/AggregateFunctions/AggregateFunctionGroupBitmapData.h @@ -576,6 +576,8 @@ public: { if (isSmall()) { + if (small.size()) + return 0; auto min_val = std::numeric_limits>::max(); for (const auto & x : small) { @@ -593,11 +595,13 @@ public: { if (isSmall()) { + if (small.size()) + return 0; auto max_val = std::numeric_limits>::min(); for (const auto & x : small) { auto val = x.getValue(); - if (val < max_val) + if (val > max_val) max_val = val; } return max_val; diff --git a/tests/queries/0_stateless/00829_bitmap_function.reference b/tests/queries/0_stateless/00829_bitmap_function.reference index e03a7300db0..02633af568d 100644 --- a/tests/queries/0_stateless/00829_bitmap_function.reference +++ b/tests/queries/0_stateless/00829_bitmap_function.reference @@ -91,9 +91,9 @@ tag4 [0,1,2,3,4,5,6,7,8,9] [5,999,2] [2,888,20] [0,1,3,4,6,7,8,9,20] [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,100,200,500] [30,31,32,33,100,200,500] [100,200,500] -4294967295 -4294967295 -4294967295 +0 +0 +0 1 0 0