This is an automated email from the ASF dual-hosted git repository.
Fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/parquet-java.git
The following commit(s) were added to refs/heads/master by this push:
new 2c9fbb360 Revert "GH-3574: Statistics.toParquetStatistics always set
null_count(#3575)" (#3688)
2c9fbb360 is described below
commit 2c9fbb360e32cf19045f68ac27eee9b593c966f5
Author: Fokko Driesprong <[email protected]>
AuthorDate: Mon Jul 27 22:07:01 2026 +0200
Revert "GH-3574: Statistics.toParquetStatistics always set
null_count(#3575)" (#3688)
This reverts commit 63aebcc0cf3684ba6c9dc2b7243c6007d3a1269f.
---
.../parquet/format/converter/ParquetMetadataConverter.java | 10 ++++------
.../format/converter/TestParquetMetadataConverter.java | 11 +++++------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git
a/parquet-hadoop/src/main/java/org/apache/parquet/format/converter/ParquetMetadataConverter.java
b/parquet-hadoop/src/main/java/org/apache/parquet/format/converter/ParquetMetadataConverter.java
index 8600b2ced..465516e48 100644
---
a/parquet-hadoop/src/main/java/org/apache/parquet/format/converter/ParquetMetadataConverter.java
+++
b/parquet-hadoop/src/main/java/org/apache/parquet/format/converter/ParquetMetadataConverter.java
@@ -815,17 +815,15 @@ public class ParquetMetadataConverter {
public static Statistics toParquetStatistics(
org.apache.parquet.column.statistics.Statistics stats, int
truncateLength) {
Statistics formatStats = new Statistics();
- if (!stats.isEmpty()) {
- formatStats.setNull_count(stats.getNumNulls());
- if (stats.isNanCountSet()) {
- formatStats.setNan_count(stats.getNanCount());
- }
- }
// Don't write stats larger than the max size rather than truncating. The
// rationale is that some engines may use the minimum value in the page as
// the true minimum for aggregations and there is no way to mark that a
// value has been truncated and is a lower bound and not in the page.
if (!stats.isEmpty() && withinLimit(stats, truncateLength)) {
+ formatStats.setNull_count(stats.getNumNulls());
+ if (stats.isNanCountSet()) {
+ formatStats.setNan_count(stats.getNanCount());
+ }
if (stats.hasNonNullValue()) {
byte[] min;
byte[] max;
diff --git
a/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
b/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
index c6deee285..4d361d6aa 100644
---
a/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
+++
b/parquet-hadoop/src/test/java/org/apache/parquet/format/converter/TestParquetMetadataConverter.java
@@ -878,7 +878,7 @@ public class TestParquetMetadataConverter {
}
assertThat(formatStats.getNull_count()).as("Num nulls should
match").isEqualTo(3004);
- // min/max are not written because the values are too large, but null
count is always written
+ // convert to empty stats because the values are too large
stats.setMinMaxFromBytes(max, max);
formatStats = helper.toParquetStatistics(stats);
@@ -891,7 +891,9 @@ public class TestParquetMetadataConverter {
assertThat(formatStats.isSetMax_value())
.as("Max_value should not be set")
.isFalse();
- assertThat(formatStats.getNull_count()).as("Num nulls should
match").isEqualTo(3004);
+ assertThat(formatStats.isSetNull_count())
+ .as("Num nulls should not be set")
+ .isFalse();
Statistics roundTripStats =
ParquetMetadataConverter.fromParquetStatisticsInternal(
Version.FULL_VERSION,
@@ -901,10 +903,7 @@ public class TestParquetMetadataConverter {
assertThat(roundTripStats.isEmpty())
.as("Round-trip stats should not be empty (null count is set)")
- .isFalse();
- assertThat(roundTripStats.getNumNulls())
- .as("Round-trip null count should match")
- .isEqualTo(3004);
+ .isTrue();
}
@Test