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


##########
cpp/src/parquet/arrow/reader_internal.cc:
##########
@@ -330,15 +331,30 @@ Status TransferInt(RecordReader* reader, MemoryPool* pool,
   auto values = reinterpret_cast<const ParquetCType*>(reader->values());
   auto out_ptr = reinterpret_cast<ArrowCType*>(data->mutable_data());
   std::copy(values, values + length, out_ptr);
+  int64_t null_count = 0;
+  std::vector<std::shared_ptr<Buffer>> buffers = {nullptr, std::move(data)};
   if (field->nullable()) {
-    *out = std::make_shared<ArrayType<ArrowType>>(field->type(), length, 
std::move(data),
-                                                  reader->ReleaseIsValid(),
-                                                  reader->null_count());
-  } else {
-    *out =
-        std::make_shared<ArrayType<ArrowType>>(field->type(), length, 
std::move(data),
-                                               /*null_bitmap=*/nullptr, 
/*null_count=*/0);
+    null_count = reader->null_count();
+    buffers[0] = reader->ReleaseIsValid();
+  }
+  auto array_data =
+      ::arrow::ArrayData::Make(field->type(), length, std::move(buffers), 
null_count);
+  array_data->statistics.null_count = null_count;
+  auto statistics = metadata->statistics().get();
+  if (statistics) {
+    if (statistics->HasDistinctCount()) {
+      array_data->statistics.distinct_count = statistics->distinct_count();
+    }
+    if (statistics->HasMinMax()) {
+      auto typed_statistics =
+          static_cast<::parquet::TypedStatistics<ParquetType>*>(statistics);
+      array_data->statistics.min_buffer =
+          static_cast<ArrowCType>(typed_statistics->min());
+      array_data->statistics.max_buffer =
+          static_cast<ArrowCType>(typed_statistics->max());
+    }
   }
+  *out = std::make_shared<ArrayType<ArrowType>>(std::move(array_data));

Review Comment:
   We don't need to merge. Because each `arrow::Array` in a `arrow::Table` can 
have statistics.
   We may add `arrow::Table`/`arrow::RecordBatch` (row group) level statistics 
later but it's out of scope of this proposal.



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