rdblue commented on code in PR #6965:
URL: https://github.com/apache/iceberg/pull/6965#discussion_r1125768603
##########
core/src/main/java/org/apache/iceberg/util/SnapshotUtil.java:
##########
@@ -424,14 +424,25 @@ public static Snapshot latestSnapshot(Table table, String
branch) {
* old code path to ensure backwards compatibility.
*
* @param metadata a {@link TableMetadata}
- * @param branch branch name of the table metadata
+ * @param branch branch name of the table metadata (nullable)
* @return the latest snapshot for the given branch
*/
public static Snapshot latestSnapshot(TableMetadata metadata, String branch)
{
- if (branch.equals(SnapshotRef.MAIN_BRANCH)) {
+ if (branch == null || branch.equals(SnapshotRef.MAIN_BRANCH)) {
return metadata.currentSnapshot();
}
return metadata.snapshot(metadata.ref(branch).snapshotId());
}
+
+ /**
+ * Return the schema of the snapshot at a given branch
+ *
+ * @param table a {@link Table}
+ * @param branch branch name of the table (nullable)
+ * @return schema of the specific snapshot at the given branch
+ */
+ public static Schema snapshotSchema(Table table, String branch) {
+ return branch == null ? table.schema() :
table.schemas().get(table.snapshot(branch).schemaId());
Review Comment:
I think this should also check for `main`. That way if the branch is `main`
but there is no current snapshot, the table schema is returned.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]