kou commented on code in PR #46385:
URL: https://github.com/apache/arrow/pull/46385#discussion_r2083294008


##########
cpp/src/arrow/array/array_test.cc:
##########
@@ -3899,6 +3903,10 @@ TEST_F(TestArrayDataStatistics, MoveConstructor) {
   
ASSERT_TRUE(std::holds_alternative<int64_t>(moved_data.statistics->max.value()));
   ASSERT_EQ(max_, std::get<int64_t>(moved_data.statistics->max.value()));
   ASSERT_TRUE(moved_data.statistics->is_max_exact);
+
+  ASSERT_TRUE(moved_data.statistics->average_byte_width.has_value());
+  ASSERT_EQ(average_byte_width_, 
moved_data.statistics->average_byte_width.value());

Review Comment:
   We should not use `ASSERT_EQ()` for floating point numbers.
   
   We should use `ASSERT_FLOAT_EQ()`/`ASSERT_DOUBLE_EQ()` for them. See also: 
https://google.github.io/googletest/reference/assertions.html#floating-point



##########
cpp/src/arrow/array/statistics.h:
##########
@@ -77,6 +77,12 @@ struct ARROW_EXPORT ArrayStatistics {
   /// \brief The number of distinct values, may not be set
   std::optional<int64_t> distinct_count = std::nullopt;
 
+  /// \brief The average size in bytes of a row in an array, may not be set
+  std::optional<double> average_byte_width = std::nullopt;
+
+  /// \brief Whether the average_byte_width value is exact or not

Review Comment:
   ```suggestion
     /// \brief Whether the average size in bytes is exact or not
   ```



##########
cpp/src/arrow/array/statistics.h:
##########
@@ -131,7 +137,9 @@ struct ARROW_EXPORT ArrayStatistics {
   bool Equals(const ArrayStatistics& other) const {
     return null_count == other.null_count && distinct_count == 
other.distinct_count &&
            min == other.min && is_min_exact == other.is_min_exact && max == 
other.max &&
-           is_max_exact == other.is_max_exact;
+           is_max_exact == other.is_max_exact &&
+           average_byte_width == other.average_byte_width &&

Review Comment:
   We should not use `==` for floating point numbers.
   We need something like 
https://github.com/apache/arrow/blob/598938711a8376cbfdceaf5c77ab0fd5057e6c02/cpp/src/arrow/compare.cc#L85-L94
 instead.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to