wypoon commented on a change in pull request #1508: URL: https://github.com/apache/iceberg/pull/1508#discussion_r501457611
########## 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: I have kept `schemaForSnapshotAsOfTime` for convenience. Since the `Table` API is unchanged, I think it is ok. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org