diff --git a/core/src/main/java/org/apache/iceberg/PartitionsTable.java b/core/src/main/java/org/apache/iceberg/PartitionsTable.java index e0b89df6d714..ca81b19f1777 100644 --- a/core/src/main/java/org/apache/iceberg/PartitionsTable.java +++ b/core/src/main/java/org/apache/iceberg/PartitionsTable.java @@ -45,9 +45,10 @@ public class PartitionsTable extends BaseMetadataTable { super(ops, table, name); this.schema = new Schema( - Types.NestedField.required(1, "partition", table.spec().partitionType()), + Types.NestedField.required(1, "partition", Partitioning.partitionType(table)), Types.NestedField.required(2, "record_count", Types.LongType.get()), - Types.NestedField.required(3, "file_count", Types.IntegerType.get()) + Types.NestedField.required(3, "file_count", Types.IntegerType.get()), + Types.NestedField.required(4, "spec_id", Types.IntegerType.get()) ); } @@ -89,7 +90,7 @@ private DataTask task(StaticTableScan scan) { } private static StaticDataTask.Row convertPartition(Partition partition) { - return StaticDataTask.Row.of(partition.key, partition.recordCount, partition.fileCount); + return StaticDataTask.Row.of(partition.key, partition.recordCount, partition.fileCount, partition.specId); } private static Iterable partitions(StaticTableScan scan) { @@ -167,16 +168,19 @@ static class Partition { private final StructLike key; private long recordCount; private int fileCount; + private int specId; Partition(StructLike key) { this.key = key; this.recordCount = 0; this.fileCount = 0; + this.specId = 0; } void update(DataFile file) { this.recordCount += file.recordCount(); this.fileCount += 1; + this.specId = file.specId(); } } } diff --git a/spark/v2.4/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java b/spark/v2.4/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java index 791e63e4506c..30bfb89a1048 100644 --- a/spark/v2.4/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java +++ b/spark/v2.4/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java @@ -1110,11 +1110,13 @@ public void testPartitionsTable() { .set("partition", partitionBuilder.set("id", 1).build()) .set("record_count", 1L) .set("file_count", 1) + .set("spec_id", 0) .build()); expected.add(builder .set("partition", partitionBuilder.set("id", 2).build()) .set("record_count", 1L) .set("file_count", 1) + .set("spec_id", 0) .build()); Assert.assertEquals("Partitions table should have two rows", 2, expected.size()); diff --git a/spark/v3.0/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java b/spark/v3.0/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java index 78137d139dbf..89764018ffc5 100644 --- a/spark/v3.0/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java +++ b/spark/v3.0/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java @@ -1111,11 +1111,13 @@ public void testPartitionsTable() { .set("partition", partitionBuilder.set("id", 1).build()) .set("record_count", 1L) .set("file_count", 1) + .set("spec_id", 0) .build()); expected.add(builder .set("partition", partitionBuilder.set("id", 2).build()) .set("record_count", 1L) .set("file_count", 1) + .set("spec_id", 0) .build()); Assert.assertEquals("Partitions table should have two rows", 2, expected.size()); diff --git a/spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java b/spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java index 78137d139dbf..89764018ffc5 100644 --- a/spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java +++ b/spark/v3.1/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java @@ -1111,11 +1111,13 @@ public void testPartitionsTable() { .set("partition", partitionBuilder.set("id", 1).build()) .set("record_count", 1L) .set("file_count", 1) + .set("spec_id", 0) .build()); expected.add(builder .set("partition", partitionBuilder.set("id", 2).build()) .set("record_count", 1L) .set("file_count", 1) + .set("spec_id", 0) .build()); Assert.assertEquals("Partitions table should have two rows", 2, expected.size()); diff --git a/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java b/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java index af6a75a34736..c47c4c0a2db2 100644 --- a/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java +++ b/spark/v3.2/spark/src/test/java/org/apache/iceberg/spark/source/TestIcebergSourceTablesBase.java @@ -1112,11 +1112,13 @@ public void testPartitionsTable() { .set("partition", partitionBuilder.set("id", 1).build()) .set("record_count", 1L) .set("file_count", 1) + .set("spec_id", 0) .build()); expected.add(builder .set("partition", partitionBuilder.set("id", 2).build()) .set("record_count", 1L) .set("file_count", 1) + .set("spec_id", 0) .build()); Assert.assertEquals("Partitions table should have two rows", 2, expected.size());