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


##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java:
##########
@@ -159,7 +160,15 @@ public Table loadTable(Identifier ident, String version) 
throws NoSuchTableExcep
           sparkTable.snapshotId() == null,
           "Cannot do time-travel based on both table identifier and AS OF");
 
-      return sparkTable.copyWithSnapshotId(Long.parseLong(version));
+      try {
+        return sparkTable.copyWithSnapshotId(Long.parseLong(version));
+      } catch (NumberFormatException e) {
+        SnapshotRef ref = sparkTable.table().refs().get(version);
+        ValidationException.check(
+            ref != null,
+            "Cannot find matching snapshot ID or reference name for version " 
+ version);
+        return sparkTable.copyWithSnapshotId(ref.snapshotId());

Review Comment:
   I think one thing that might be useful is to time travel in a branch, 
something like `FOR SYSTEM_VERSION AS OF branchName@123456789012`. But that 
feels very hacky, I' rather have some syntax as we have been suggesting like 
`SELECT * FROM table BRANCH branch FOR SYSTEM_TIME AS OF xxx`. So I am leaving 
that part out of the implementation for now. At least I think most people can 
agree that a tag/branch head can be viewed as a version to travel to.



-- 
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