| 315 | |
| 316 | template <typename ArrowType, typename MinMaxType> |
| 317 | void TestStatisticsReadArray(std::shared_ptr<::arrow::DataType> arrow_type) { |
| 318 | using ArrowArrayType = typename ::arrow::TypeTraits<ArrowType>::ArrayType; |
| 319 | using ArrowArrayBuilder = typename ::arrow::TypeTraits<ArrowType>::BuilderType; |
| 320 | using ArrowCType = typename ArrowType::c_type; |
| 321 | constexpr auto min = std::numeric_limits<ArrowCType>::lowest(); |
| 322 | constexpr auto max = std::numeric_limits<ArrowCType>::max(); |
| 323 | |
| 324 | std::unique_ptr<ArrowArrayBuilder> builder; |
| 325 | if constexpr (::arrow::TypeTraits<ArrowType>::is_parameter_free) { |
| 326 | builder = std::make_unique<ArrowArrayBuilder>(::arrow::default_memory_pool()); |
| 327 | } else { |
| 328 | builder = |
| 329 | std::make_unique<ArrowArrayBuilder>(arrow_type, ::arrow::default_memory_pool()); |
| 330 | } |
| 331 | ASSERT_OK(builder->Append(max)); |
| 332 | ASSERT_OK(builder->AppendNull()); |
| 333 | ASSERT_OK(builder->Append(min)); |
| 334 | ASSERT_OK(builder->Append(max)); |
| 335 | ASSERT_OK_AND_ASSIGN(auto built_array, builder->Finish()); |
| 336 | ASSERT_OK_AND_ASSIGN(auto read_array, |
| 337 | StatisticsReadArray(arrow_type, std::move(built_array))); |
| 338 | auto typed_read_array = std::static_pointer_cast<ArrowArrayType>(read_array); |
| 339 | auto statistics = typed_read_array->statistics(); |
| 340 | ASSERT_NE(nullptr, statistics); |
| 341 | ASSERT_EQ(true, statistics->null_count.has_value()); |
| 342 | ASSERT_EQ(true, std::holds_alternative<int64_t>(statistics->null_count.value())); |
| 343 | ASSERT_EQ(1, std::get<int64_t>(statistics->null_count.value())); |
| 344 | ASSERT_EQ(false, statistics->distinct_count.has_value()); |
| 345 | ASSERT_EQ(true, statistics->min.has_value()); |
| 346 | ASSERT_EQ(true, std::holds_alternative<MinMaxType>(*statistics->min)); |
| 347 | ASSERT_EQ(min, std::get<MinMaxType>(*statistics->min)); |
| 348 | ASSERT_EQ(true, statistics->is_min_exact); |
| 349 | ASSERT_EQ(true, statistics->max.has_value()); |
| 350 | ASSERT_EQ(true, std::holds_alternative<MinMaxType>(*statistics->max)); |
| 351 | ASSERT_EQ(max, std::get<MinMaxType>(*statistics->max)); |
| 352 | ASSERT_EQ(true, statistics->is_min_exact); |
| 353 | } |
| 354 | } // namespace |
| 355 | |
| 356 | TEST(TestStatisticsRead, Boolean) { |
nothing calls this directly
no test coverage detected