Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ public Builder withStatisticsEnabled(String columnPath, boolean enabled) {
}

public Builder withStatisticsEnabled(boolean enabled) {
this.statistics.withDefaultValue(enabled);
this.statisticsEnabled = enabled;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ private void testParquetFileNumberOfBlocks(
}

@Test
public void testSizeStatisticsControl() throws Exception {
public void testSizeStatisticsAndStatisticsControl() throws Exception {
MessageType schema = Types.buildMessage()
.required(BINARY)
.named("string_field")
Expand All @@ -568,6 +568,7 @@ public void testSizeStatisticsControl() throws Exception {
try (ParquetWriter<Group> writer = ExampleParquetWriter.builder(path)
.withType(schema)
.withSizeStatisticsEnabled(false)
.withStatisticsEnabled(false) // Disable column statistics globally
.build()) {
writer.write(group);
}
Expand All @@ -576,6 +577,7 @@ public void testSizeStatisticsControl() throws Exception {
// Verify size statistics are disabled globally
for (BlockMetaData block : reader.getFooter().getBlocks()) {
for (ColumnChunkMetaData column : block.getColumns()) {
assertTrue(column.getStatistics().isEmpty()); // Make sure there is no column statistics
assertNull(column.getSizeStatistics());
}
}
Expand All @@ -589,6 +591,7 @@ public void testSizeStatisticsControl() throws Exception {
.withType(schema)
.withSizeStatisticsEnabled(true) // enable globally
.withSizeStatisticsEnabled("boolean_field", false) // disable for specific column
.withStatisticsEnabled("boolean_field", false) // disable column statistics
.build()) {
writer.write(group);
}
Expand All @@ -599,8 +602,10 @@ public void testSizeStatisticsControl() throws Exception {
for (ColumnChunkMetaData column : block.getColumns()) {
if (column.getPath().toDotString().equals("boolean_field")) {
assertNull(column.getSizeStatistics());
assertTrue(column.getStatistics().isEmpty());
} else {
assertTrue(column.getSizeStatistics().isValid());
assertFalse(column.getStatistics().isEmpty());
}
}
}
Expand Down