Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-3133: Fix SizeStatistics to handle omitted histogram #3135

Open
wants to merge 3 commits into
base: parquet-1.15.x
Choose a base branch
from
Open
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 @@ -136,8 +136,10 @@ public SizeStatistics(
List<Long> definitionLevelHistogram) {
this.type = type;
this.unencodedByteArrayDataBytes = unencodedByteArrayDataBytes;
this.repetitionLevelHistogram = repetitionLevelHistogram;
this.definitionLevelHistogram = definitionLevelHistogram;
this.repetitionLevelHistogram =
repetitionLevelHistogram == null ? Collections.emptyList() : repetitionLevelHistogram;
this.definitionLevelHistogram =
definitionLevelHistogram == null ? Collections.emptyList() : definitionLevelHistogram;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.parquet.column.statistics;

import java.util.Arrays;
import java.util.Collections;
import java.util.Optional;
import org.apache.parquet.io.api.Binary;
import org.apache.parquet.schema.LogicalTypeAnnotation;
Expand Down Expand Up @@ -124,4 +125,20 @@ public void testCopyStatistics() {
Assert.assertEquals(Arrays.asList(1L, 1L, 1L), copy.getRepetitionLevelHistogram());
Assert.assertEquals(Arrays.asList(1L, 1L, 1L), copy.getDefinitionLevelHistogram());
}

@Test
public void testOmittedHistogram() {
PrimitiveType type = Types.optional(PrimitiveType.PrimitiveTypeName.BINARY)
.as(LogicalTypeAnnotation.stringType())
.named("a");
SizeStatistics statistics = new SizeStatistics(type, 1024L, null, null);
Assert.assertEquals(Optional.of(1024L), statistics.getUnencodedByteArrayDataBytes());
Assert.assertEquals(Collections.emptyList(), statistics.getRepetitionLevelHistogram());
Assert.assertEquals(Collections.emptyList(), statistics.getDefinitionLevelHistogram());

SizeStatistics copy = statistics.copy();
Assert.assertEquals(Optional.of(1024L), copy.getUnencodedByteArrayDataBytes());
Assert.assertEquals(Collections.emptyList(), copy.getRepetitionLevelHistogram());
Assert.assertEquals(Collections.emptyList(), copy.getDefinitionLevelHistogram());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2382,8 +2382,14 @@ public static SizeStatistics toParquetSizeStatistics(org.apache.parquet.column.s
formatStats.setUnencoded_byte_array_data_bytes(
stats.getUnencodedByteArrayDataBytes().get());
}
formatStats.setRepetition_level_histogram(stats.getRepetitionLevelHistogram());
formatStats.setDefinition_level_histogram(stats.getDefinitionLevelHistogram());
List<Long> repLevelHistogram = stats.getRepetitionLevelHistogram();
if (repLevelHistogram != null && !repLevelHistogram.isEmpty()) {
formatStats.setRepetition_level_histogram(repLevelHistogram);
}
List<Long> defLevelHistogram = stats.getDefinitionLevelHistogram();
if (defLevelHistogram != null && !defLevelHistogram.isEmpty()) {
formatStats.setDefinition_level_histogram(defLevelHistogram);
}
return formatStats;
}
}
2 changes: 1 addition & 1 deletion parquet-plugins/parquet-encoding-vector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.parquet</groupId>
<artifactId>parquet</artifactId>
<version>1.15.0-SNAPSHOT</version>
<version>1.15.1-SNAPSHOT</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed? Is it because this was overlooked before?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release process does not automatically update this...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, maybe we should fix it later.

<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion parquet-plugins/parquet-plugins-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.parquet</groupId>
<artifactId>parquet</artifactId>
<version>1.15.0-SNAPSHOT</version>
<version>1.15.1-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

Expand Down
Loading