-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Core: Minor refactoring of PartitionsTable #6975
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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()), | ||
| 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")); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docs should use sentence case. |
||
| } | ||
|
|
||
| @Override | ||
|
|
@@ -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)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()), | ||
|
|
@@ -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) { | ||
|
|
@@ -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(); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docs should use sentence case here as well. |
||
| .asStruct(); | ||
|
|
||
| TableScan scanWithProjection = partitionsTable.newScan().select("file_count"); | ||
| Assert.assertEquals(expected, scanWithProjection.schema().asStruct()); | ||
|
|
||
There was a problem hiding this comment.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.