diff --git a/cpp/src/arrow/array/statistics.h b/cpp/src/arrow/array/statistics.h index 816d68e777696..523f877bbe429 100644 --- a/cpp/src/arrow/array/statistics.h +++ b/cpp/src/arrow/array/statistics.h @@ -43,14 +43,14 @@ struct ARROW_EXPORT ArrayStatistics { /// \brief The minimum value, may not be set std::optional min = std::nullopt; - /// \brief Whether the minimum value is exact or not, may not be set - std::optional is_min_exact = std::nullopt; + /// \brief Whether the minimum value is exact or not + bool is_min_exact = false; /// \brief The maximum value, may not be set std::optional max = std::nullopt; - /// \brief Whether the maximum value is exact or not, may not be set - std::optional is_max_exact = std::nullopt; + /// \brief Whether the maximum value is exact or not + bool is_max_exact = false; /// \brief Check two statistics for equality bool Equals(const ArrayStatistics& other) const { diff --git a/cpp/src/arrow/array/statistics_test.cc b/cpp/src/arrow/array/statistics_test.cc index f4f4f50015140..cf15a5d382978 100644 --- a/cpp/src/arrow/array/statistics_test.cc +++ b/cpp/src/arrow/array/statistics_test.cc @@ -40,27 +40,25 @@ TEST(ArrayStatisticsTest, TestDistinctCount) { TEST(ArrayStatisticsTest, TestMin) { ArrayStatistics statistics; ASSERT_FALSE(statistics.min.has_value()); - ASSERT_FALSE(statistics.is_min_exact.has_value()); + ASSERT_FALSE(statistics.is_min_exact); statistics.min = static_cast(29); statistics.is_min_exact = true; ASSERT_TRUE(statistics.min.has_value()); ASSERT_TRUE(std::holds_alternative(statistics.min.value())); ASSERT_EQ(29, std::get(statistics.min.value())); - ASSERT_TRUE(statistics.is_min_exact.has_value()); - ASSERT_TRUE(statistics.is_min_exact.value()); + ASSERT_TRUE(statistics.is_min_exact); } TEST(ArrayStatisticsTest, TestMax) { ArrayStatistics statistics; ASSERT_FALSE(statistics.max.has_value()); - ASSERT_FALSE(statistics.is_max_exact.has_value()); + ASSERT_FALSE(statistics.is_max_exact); statistics.max = std::string("hello"); statistics.is_max_exact = false; ASSERT_TRUE(statistics.max.has_value()); ASSERT_TRUE(std::holds_alternative(statistics.max.value())); ASSERT_EQ("hello", std::get(statistics.max.value())); - ASSERT_TRUE(statistics.is_max_exact.has_value()); - ASSERT_FALSE(statistics.is_max_exact.value()); + ASSERT_FALSE(statistics.is_max_exact); } TEST(ArrayStatisticsTest, TestEquality) { @@ -84,9 +82,9 @@ TEST(ArrayStatisticsTest, TestEquality) { statistics2.min = std::string("world"); ASSERT_EQ(statistics1, statistics2); - statistics1.is_min_exact = false; + statistics1.is_min_exact = true; ASSERT_NE(statistics1, statistics2); - statistics2.is_min_exact = false; + statistics2.is_min_exact = true; ASSERT_EQ(statistics1, statistics2); statistics1.max = static_cast(-29);