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


##########
cpp/src/arrow/record_batch_test.cc:
##########
@@ -1424,33 +1471,86 @@ TEST_F(TestRecordBatch, 
MakeStatisticsArrayMaxApproximate) {
 }
 
 TEST_F(TestRecordBatch, MakeStatisticsArrayString) {
-  auto schema =
-      ::arrow::schema({field("no-statistics", boolean()), field("string", 
utf8())});
-  auto no_statistics_array = ArrayFromJSON(boolean(), "[true, false, true]");
-  auto string_array_data = ArrayFromJSON(utf8(), "[\"a\", null, 
\"c\"]")->data()->Copy();
-  string_array_data->statistics = std::make_shared<ArrayStatistics>();
-  string_array_data->statistics->is_max_exact = true;
-  string_array_data->statistics->max = "c";
-  auto string_array = MakeArray(std::move(string_array_data));
-  auto batch = RecordBatch::Make(schema, string_array->length(),
-                                 {no_statistics_array, string_array});
+  auto CheckString = [](const std::shared_ptr<DataType>& type) {
+    auto schema =
+        ::arrow::schema({field("no-statistics", boolean()), field("string", 
type)});
+    auto no_statistics_array = ArrayFromJSON(boolean(), "[true, false, true]");
+    auto string_array_data = ArrayFromJSON(type, "[\"a\", null, 
\"c\"]")->data()->Copy();
+    string_array_data->statistics = std::make_shared<ArrayStatistics>();
+    string_array_data->statistics->is_max_exact = true;
+    string_array_data->statistics->max = "c";
+    auto string_array = MakeArray(std::move(string_array_data));
+    auto batch = RecordBatch::Make(schema, string_array->length(),
+                                   {no_statistics_array, string_array});
+
+    ASSERT_OK_AND_ASSIGN(auto statistics_array, batch->MakeStatisticsArray());
+
+    ASSERT_OK_AND_ASSIGN(auto expected_statistics_array,
+                         MakeStatisticsArray("[null, 1]",
+                                             {{
+                                                  
ARROW_STATISTICS_KEY_ROW_COUNT_EXACT,
+                                              },
+                                              {
+                                                  
ARROW_STATISTICS_KEY_MAX_VALUE_EXACT,
+                                              }},
+                                             {{
+                                                  
ArrayStatistics::ValueType{int64_t{3}},
+                                              },
+                                              {
+                                                  
ArrayStatistics::ValueType{"c"},
+                                              }},
+                                             {nullptr, type}));
+    AssertArraysEqual(*expected_statistics_array, *statistics_array, true);
+  };
 
+  // Check each type
+  CheckString(binary());
+  CheckString(utf8());
+  CheckString(large_binary());
+  CheckString(large_utf8());
+  CheckString(binary_view());
+  CheckString(utf8_view());
+  CheckString(fixed_size_binary(1));
+
+  // Check the combination of various string types

Review Comment:
   How about creating a separated test for it instead of mixing it to existing 
tests?



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to