adriangb commented on code in PR #27876:
URL: https://github.com/apache/datafusion/pull/27876#discussion_r4764426772
##########
datafusion/core/tests/parquet/struct_field_pruning.rs:
##########
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for
additional information regarding copyright ownership
+// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF)
under one or more contributor license agreements
+
+//! Pruning on struct fields, for files that SQL cannot write.
+
+use std::io::Write;
+use std::sync::Arc;
+
+use arrow::array::{ArrayRef, Int64Array, RecordBatch, StructArray};
+use arrow::datatypes::{DataType, Field, Fields, Schema};
+use datafusion::prelude::{ParquetReadOptions, SessionContext};
+use datafusion_common::ScalarValue;
+use parquet::arrow::ArrowWriter;
+use parquet::file::metadata::{ParquetMetaData, ParquetMetaDataWriter};
+use parquet::file::statistics::Statistics;
+use parquet::file::writer::TrackedWrite;
+use tempfile::NamedTempFile;
+
+/// Writes `s: {a: Int64}` with rows `{a: 1}` and `{a: null}` in one row
+/// group. The footer keeps the min and max of `s.a`, but not its null count.
+fn struct_file_without_null_count() -> NamedTempFile {
Review Comment:
The purpose was to check that the new code that reads struct field
statistics treats a missing null count as unknown, the same as the existing
column path does since https://github.com/apache/datafusion/pull/25242. It is
not a struct-specific problem: `StatisticsConverter` reads a missing count as
zero for any column unless the caller sets
`with_missing_null_counts_as_zero(false)`.
Old parquet-rs used to write offending files, current releases don’t. I
looked into committing an offending file but in the end opted for a unit test.
The purpose was to guard the struct field path against reading a missing
null count as zero, which `StatisticsConverter` does unless the caller sets
`with_missing_null_counts_as_zero(false)` (the default from
https://github.com/apache/arrow-rs/pull/6485, which DataFusion turned off in
https://github.com/apache/datafusion/pull/25242).
For top level column `row_group_pruning_predicate_missing_null_count`
already covers the case with in-memory metadata, and
https://github.com/apache/datafusion/pull/27736 now has the same unit test for
a struct field, next to the code that reads its statistics.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]