Search in sources :

Example 1 with PartitionFieldSummary

use of org.apache.iceberg.ManifestFile.PartitionFieldSummary in project iceberg by apache.

the class TestManifestFileSerialization method checkManifestFile.

private void checkManifestFile(ManifestFile expected, ManifestFile actual) {
    Assert.assertEquals("Path must match", expected.path(), actual.path());
    Assert.assertEquals("Length must match", expected.length(), actual.length());
    Assert.assertEquals("Spec id must match", expected.partitionSpecId(), actual.partitionSpecId());
    Assert.assertEquals("Snapshot id must match", expected.snapshotId(), actual.snapshotId());
    Assert.assertEquals("Added files flag must match", expected.hasAddedFiles(), actual.hasAddedFiles());
    Assert.assertEquals("Added files count must match", expected.addedFilesCount(), actual.addedFilesCount());
    Assert.assertEquals("Added rows count must match", expected.addedRowsCount(), actual.addedRowsCount());
    Assert.assertEquals("Existing files flag must match", expected.hasExistingFiles(), actual.hasExistingFiles());
    Assert.assertEquals("Existing files count must match", expected.existingFilesCount(), actual.existingFilesCount());
    Assert.assertEquals("Existing rows count must match", expected.existingRowsCount(), actual.existingRowsCount());
    Assert.assertEquals("Deleted files flag must match", expected.hasDeletedFiles(), actual.hasDeletedFiles());
    Assert.assertEquals("Deleted files count must match", expected.deletedFilesCount(), actual.deletedFilesCount());
    Assert.assertEquals("Deleted rows count must match", expected.deletedRowsCount(), actual.deletedRowsCount());
    PartitionFieldSummary expectedPartition = expected.partitions().get(0);
    PartitionFieldSummary actualPartition = actual.partitions().get(0);
    Assert.assertEquals("Null flag in partition must match", expectedPartition.containsNull(), actualPartition.containsNull());
    Assert.assertEquals("NaN flag in partition must match", expectedPartition.containsNaN(), actualPartition.containsNaN());
    Assert.assertEquals("Lower bounds in partition must match", expectedPartition.lowerBound(), actualPartition.lowerBound());
    Assert.assertEquals("Upper bounds in partition must match", expectedPartition.upperBound(), actualPartition.upperBound());
}
Also used : PartitionFieldSummary(org.apache.iceberg.ManifestFile.PartitionFieldSummary)

Example 2 with PartitionFieldSummary

use of org.apache.iceberg.ManifestFile.PartitionFieldSummary in project trino by trinodb.

the class ManifestsTable method writePartitionSummaries.

private static void writePartitionSummaries(BlockBuilder arrayBlockBuilder, List<PartitionFieldSummary> summaries, PartitionSpec partitionSpec) {
    BlockBuilder singleArrayWriter = arrayBlockBuilder.beginBlockEntry();
    for (int i = 0; i < summaries.size(); i++) {
        PartitionFieldSummary summary = summaries.get(i);
        PartitionField field = partitionSpec.fields().get(i);
        Type nestedType = partitionSpec.partitionType().fields().get(i).type();
        BlockBuilder rowBuilder = singleArrayWriter.beginBlockEntry();
        BOOLEAN.writeBoolean(rowBuilder, summary.containsNull());
        BOOLEAN.writeBoolean(rowBuilder, summary.containsNaN());
        VARCHAR.writeString(rowBuilder, field.transform().toHumanString(Conversions.fromByteBuffer(nestedType, summary.lowerBound())));
        VARCHAR.writeString(rowBuilder, field.transform().toHumanString(Conversions.fromByteBuffer(nestedType, summary.upperBound())));
        singleArrayWriter.closeEntry();
    }
    arrayBlockBuilder.closeEntry();
}
Also used : PartitionField(org.apache.iceberg.PartitionField) RowType(io.trino.spi.type.RowType) ArrayType(io.trino.spi.type.ArrayType) Type(org.apache.iceberg.types.Type) PartitionFieldSummary(org.apache.iceberg.ManifestFile.PartitionFieldSummary) BlockBuilder(io.trino.spi.block.BlockBuilder)

Aggregations

PartitionFieldSummary (org.apache.iceberg.ManifestFile.PartitionFieldSummary)2 BlockBuilder (io.trino.spi.block.BlockBuilder)1 ArrayType (io.trino.spi.type.ArrayType)1 RowType (io.trino.spi.type.RowType)1 PartitionField (org.apache.iceberg.PartitionField)1 Type (org.apache.iceberg.types.Type)1