jackye1995 commented on code in PR #6717:
URL: https://github.com/apache/iceberg/pull/6717#discussion_r1103758126


##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/SparkCachedTableCatalog.java:
##########
@@ -161,9 +180,19 @@ private Pair<Table, Long> load(Identifier ident) throws 
NoSuchTableException {
       return Pair.of(table, snapshotId);
     } else if (asOfTimestamp != null) {
       return Pair.of(table, SnapshotUtil.snapshotIdAsOfTime(table, 
asOfTimestamp));
-    } else {
-      return Pair.of(table, null);
+    } else if (branch != null) {
+      Snapshot branchSnapshot = table.snapshot(branch);
+      Preconditions.checkArgument(
+          branchSnapshot != null, "Cannot find snapshot associated with branch 
name: %s", branch);
+      return Pair.of(table, branchSnapshot.snapshotId());
+    } else if (tag != null) {
+      Snapshot tagSnapshot = table.snapshot(tag);
+      Preconditions.checkArgument(
+          tagSnapshot != null, "Cannot find snapshot associated with tag name: 
%s", tag);
+      return Pair.of(table, tagSnapshot.snapshotId());
     }
+
+    return Pair.of(table, null);

Review Comment:
   nit: I think we can avoid this line change by putting it in the else clause



##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java:
##########
@@ -722,9 +757,19 @@ private Table loadFromPathIdentifier(PathIdentifier ident) 
{
       long snapshotIdAsOfTime = SnapshotUtil.snapshotIdAsOfTime(table, 
asOfTimestamp);
       return new SparkTable(table, snapshotIdAsOfTime, !cacheEnabled);
 
-    } else {
-      return new SparkTable(table, snapshotId, !cacheEnabled);
+    } else if (branch != null) {
+      Snapshot branchSnapshot = table.snapshot(branch);
+      Preconditions.checkArgument(
+          branchSnapshot != null, "Cannot find snapshot associated with branch 
name: %s", branch);
+      return new SparkTable(table, branchSnapshot.snapshotId(), !cacheEnabled);
+    } else if (tag != null) {
+      Snapshot tagSnapshot = table.snapshot(tag);
+      Preconditions.checkArgument(
+          tagSnapshot != null, "Cannot find snapshot associated with tag name: 
%s", tag);
+      return new SparkTable(table, tagSnapshot.snapshotId(), !cacheEnabled);
     }
+
+    return new SparkTable(table, snapshotId, !cacheEnabled);

Review Comment:
   nit: I think we can avoid this line change by putting it in the else clause



-- 
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: issues-unsubscr...@iceberg.apache.org

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

Reply via email to