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
24 changes: 13 additions & 11 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,11 @@ public class PartitionsTable extends BaseMetadataTable {
this.schema =
new Schema(
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(4, "spec_id", Types.IntegerType.get()));
Types.NestedField.required(4, "spec_id", Types.IntegerType.get()),
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about the column order, it feels odd to me to have IDs in 1,4,2,3 order. But that's just personal preference.

Copy link
Member Author

@ajantha-bhat ajantha-bhat Mar 2, 2023

Choose a reason for hiding this comment

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

we have discussed this here
#6661 (comment)

I think @RussellSpitzer and @szehon-ho agree that there is no impact from column re-ordering.
Spec-id in the middle really looks odd when we add other counters. I don't want to change the field id and break the compatibility.

Types.NestedField.required(
2, "record_count", Types.LongType.get(), "Count of records in data files"),
Types.NestedField.required(
3, "file_count", Types.IntegerType.get(), "Count of data files"));
}

@Override
Expand Down Expand Up @@ -77,7 +79,7 @@ private DataTask task(StaticTableScan scan) {
schema(),
scan.schema(),
partitions,
root -> StaticDataTask.Row.of(root.recordCount, root.fileCount));
root -> StaticDataTask.Row.of(root.dataRecordCount, root.dataFileCount));
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see much value in these renames, but it's okay with me.

} else {
return StaticDataTask.of(
io().newInputFile(table().operations().current().metadataFileLocation()),
Expand All @@ -90,7 +92,7 @@ private DataTask task(StaticTableScan scan) {

private static StaticDataTask.Row convertPartition(Partition partition) {
return StaticDataTask.Row.of(
partition.key, partition.recordCount, partition.fileCount, partition.specId);
partition.key, partition.specId, partition.dataRecordCount, partition.dataFileCount);
}

private static Iterable<Partition> partitions(Table table, StaticTableScan scan) {
Expand Down Expand Up @@ -220,20 +222,20 @@ Iterable<Partition> all() {

static class Partition {
private final StructLike key;
private long recordCount;
private int fileCount;
private int specId;
private long dataRecordCount;
private int dataFileCount;

Partition(StructLike key) {
this.key = key;
this.recordCount = 0;
this.fileCount = 0;
this.specId = 0;
this.dataRecordCount = 0;
this.dataFileCount = 0;
}

void update(DataFile file) {
this.recordCount += file.recordCount();
this.fileCount += 1;
this.dataRecordCount += file.recordCount();
this.dataFileCount += 1;
this.specId = file.specId();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,8 @@ public void testPartitionsTableScanWithProjection() {

Table partitionsTable = new PartitionsTable(table);
Types.StructType expected =
new Schema(required(3, "file_count", Types.IntegerType.get())).asStruct();
new Schema(required(3, "file_count", Types.IntegerType.get(), "Count of data files"))
.asStruct();

TableScan scanWithProjection = partitionsTable.newScan().select("file_count");
Assert.assertEquals(expected, scanWithProjection.schema().asStruct());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1234,8 +1234,8 @@ public void testUnpartitionedPartitionsTable() {

Types.StructType expectedSchema =
Types.StructType.of(
required(2, "record_count", Types.LongType.get()),
required(3, "file_count", Types.IntegerType.get()));
required(2, "record_count", Types.LongType.get(), "Count of records in data files"),
required(3, "file_count", Types.IntegerType.get(), "Count of data files"));

Table partitionsTable = loadTable(tableIdentifier, "partitions");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1232,8 +1232,8 @@ public void testUnpartitionedPartitionsTable() {

Types.StructType expectedSchema =
Types.StructType.of(
required(2, "record_count", Types.LongType.get()),
required(3, "file_count", Types.IntegerType.get()));
required(2, "record_count", Types.LongType.get(), "Count of records in data files"),
required(3, "file_count", Types.IntegerType.get(), "Count of data files"));

Table partitionsTable = loadTable(tableIdentifier, "partitions");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1249,8 +1249,8 @@ public void testUnpartitionedPartitionsTable() {

Types.StructType expectedSchema =
Types.StructType.of(
required(2, "record_count", Types.LongType.get()),
required(3, "file_count", Types.IntegerType.get()));
required(2, "record_count", Types.LongType.get(), "Count of records in data files"),
required(3, "file_count", Types.IntegerType.get(), "Count of data files"));

Table partitionsTable = loadTable(tableIdentifier, "partitions");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,8 @@ public void testUnpartitionedPartitionsTable() {

Types.StructType expectedSchema =
Types.StructType.of(
required(2, "record_count", Types.LongType.get()),
required(3, "file_count", Types.IntegerType.get()));
required(2, "record_count", Types.LongType.get(), "Count of records in data files"),
required(3, "file_count", Types.IntegerType.get(), "Count of data files"));

Table partitionsTable = loadTable(tableIdentifier, "partitions");

Expand Down