| 212 | |
| 213 | template <typename ArrowType, typename MinMaxType> |
| 214 | void TestStatisticsReadArray(std::shared_ptr<::arrow::DataType> arrow_type) { |
| 215 | using ArrowArrayType = typename ::arrow::TypeTraits<ArrowType>::ArrayType; |
| 216 | using ArrowArrayBuilder = typename ::arrow::TypeTraits<ArrowType>::BuilderType; |
| 217 | using ArrowCType = typename ArrowType::c_type; |
| 218 | constexpr auto min = std::numeric_limits<ArrowCType>::lowest(); |
| 219 | constexpr auto max = std::numeric_limits<ArrowCType>::max(); |
| 220 | |
| 221 | std::unique_ptr<ArrowArrayBuilder> builder; |
| 222 | if constexpr (::arrow::TypeTraits<ArrowType>::is_parameter_free) { |
| 223 | builder = std::make_unique<ArrowArrayBuilder>(::arrow::default_memory_pool()); |
| 224 | } else { |
| 225 | builder = |
| 226 | std::make_unique<ArrowArrayBuilder>(arrow_type, ::arrow::default_memory_pool()); |
| 227 | } |
| 228 | ASSERT_OK(builder->Append(max)); |
| 229 | ASSERT_OK(builder->AppendNull()); |
| 230 | ASSERT_OK(builder->Append(min)); |
| 231 | ASSERT_OK(builder->Append(max)); |
| 232 | ASSERT_OK_AND_ASSIGN(auto built_array, builder->Finish()); |
| 233 | ASSERT_OK_AND_ASSIGN(auto read_array, |
| 234 | StatisticsReadArray(arrow_type, std::move(built_array))); |
| 235 | auto typed_read_array = std::static_pointer_cast<ArrowArrayType>(read_array); |
| 236 | auto statistics = typed_read_array->statistics(); |
| 237 | ASSERT_NE(nullptr, statistics); |
| 238 | ASSERT_EQ(true, statistics->null_count.has_value()); |
| 239 | ASSERT_EQ(true, std::holds_alternative<int64_t>(statistics->null_count.value())); |
| 240 | ASSERT_EQ(1, std::get<int64_t>(statistics->null_count.value())); |
| 241 | ASSERT_EQ(false, statistics->distinct_count.has_value()); |
| 242 | ASSERT_EQ(true, statistics->min.has_value()); |
| 243 | ASSERT_EQ(true, std::holds_alternative<MinMaxType>(*statistics->min)); |
| 244 | ASSERT_EQ(min, std::get<MinMaxType>(*statistics->min)); |
| 245 | ASSERT_EQ(true, statistics->is_min_exact); |
| 246 | ASSERT_EQ(true, statistics->max.has_value()); |
| 247 | ASSERT_EQ(true, std::holds_alternative<MinMaxType>(*statistics->max)); |
| 248 | ASSERT_EQ(max, std::get<MinMaxType>(*statistics->max)); |
| 249 | ASSERT_EQ(true, statistics->is_min_exact); |
| 250 | } |
| 251 | } // namespace |
| 252 | |
| 253 | TEST(TestStatisticsRead, Boolean) { |
nothing calls this directly
no test coverage detected