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
10 changes: 7 additions & 3 deletions core/src/main/java/org/apache/iceberg/PartitionsTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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())
);
}

Expand Down Expand Up @@ -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<Partition> partitions(StaticTableScan scan) {
Expand Down Expand Up @@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down