rdblue commented on a change in pull request #1508:
URL: https://github.com/apache/iceberg/pull/1508#discussion_r497165116
##########
File path: core/src/main/java/org/apache/iceberg/BaseTable.java
##########
@@ -59,6 +60,45 @@ public Schema schema() {
return ops.current().schema();
}
+ @Override
+ public Schema schemaForSnapshot(long snapshotId) {
+ TableMetadata current = ops.current();
+ if (current.currentSnapshot() != null &&
+ current.currentSnapshot().snapshotId() == snapshotId) {
+ return current.schema();
+ }
+ Long snapshotTs = null;
+ for (HistoryEntry logEntry : current.snapshotLog()) {
+ if (logEntry.snapshotId() == snapshotId) {
+ snapshotTs = logEntry.timestampMillis();
+ }
+ }
+ Preconditions.checkArgument(snapshotTs != null,
+ "Cannot find a snapshot with id %s", snapshotId);
+ TableMetadata.MetadataLogEntry metadataLogEntry = null;
+ for (TableMetadata.MetadataLogEntry logEntry : current.previousFiles()) {
+ if (logEntry.timestampMillis() <= snapshotTs) {
+ metadataLogEntry = logEntry;
+ }
+ }
+ String metadataFile = metadataLogEntry.file();
+ TableMetadata metadata = TableMetadataParser.read(io(), metadataFile);
+ return metadata.schema();
+ }
+
+ @Override
+ public Schema schemaForSnapshotAsOfTime(long timestampMillis) {
Review comment:
Yes, the concern is that we want to keep the `Table` API small and
focused.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]