wgtmac commented on code in PR #42133:
URL: https://github.com/apache/arrow/pull/42133#discussion_r1639151970
##########
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:
The column statistics in the `ColumnChunkMetaData` is for each column chunk
in that row group. However, if I remember correctly, the parquet reader may
return arrow (chunked) arrays spanning more than one row group in a single
`RecordBatch` or `Table`. I'm not sure if we can represent correct statistics
in this case.
cc @mapleFU to confirm.
--
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]