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


##########
cpp/src/arrow/array/statistics_test.cc:
##########
@@ -25,12 +25,20 @@
 
 namespace arrow {
 
-TEST(TestArrayStatistics, NullCount) {
+TEST(TestArrayStatistics, NullCountExact) {
   ArrayStatistics statistics;
   ASSERT_FALSE(statistics.null_count.has_value());
   statistics.null_count = 29;
   ASSERT_TRUE(statistics.null_count.has_value());
-  ASSERT_EQ(29, statistics.null_count.value());
+  ASSERT_EQ(29, std::get<int64_t>(statistics.null_count.value()));
+}
+
+TEST(TestArrayStatistics, NullCountApproximate) {
+  ArrayStatistics statistics;
+  ASSERT_FALSE(statistics.null_count.has_value());
+  statistics.null_count = 29.0;
+  ASSERT_TRUE(statistics.null_count.has_value());
+  ASSERT_EQ(29.0, std::get<double>(statistics.null_count.value()));

Review Comment:
   Could you use `ASSERT_FLOAT_EQ()` for `double`?
   
   https://google.github.io/googletest/reference/assertions.html#floating-point



##########
cpp/src/arrow/record_batch.cc:
##########
@@ -541,11 +541,19 @@ Status EnumerateStatistics(const RecordBatch& 
record_batch, OnStatistics on_stat
     statistics.nth_column = nth_column;
     if (column_statistics->null_count.has_value()) {
       statistics.nth_statistics++;
-      statistics.key = ARROW_STATISTICS_KEY_NULL_COUNT_EXACT;
-      statistics.type = int64();
-      statistics.value = column_statistics->null_count.value();
-      RETURN_NOT_OK(on_statistics(statistics));
-      statistics.start_new_column = false;
+      if 
(std::holds_alternative<int64_t>(column_statistics->null_count.value())) {
+        statistics.key = ARROW_STATISTICS_KEY_NULL_COUNT_EXACT;
+        statistics.type = int64();
+        statistics.value = 
std::get<int64_t>(column_statistics->null_count.value());
+        RETURN_NOT_OK(on_statistics(statistics));
+        statistics.start_new_column = false;

Review Comment:
   Can we move them to out of this `if {} else {}`?



-- 
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