rdblue commented on a change in pull request #3269:
URL: https://github.com/apache/iceberg/pull/3269#discussion_r726542289



##########
File path: spark3/src/main/java/org/apache/iceberg/spark/SparkCatalog.java
##########
@@ -456,10 +466,97 @@ private static void checkNotPathIdentifier(Identifier 
identifier, String method)
     }
   }
 
-  private Table load(Identifier ident) {
-    return isPathIdentifier(ident) ?
-        tables.load(((PathIdentifier) ident).location()) :
-        icebergCatalog.loadTable(buildIdentifier(ident));
+  private Pair<Table, Long> load(Identifier ident) {
+    if (isPathIdentifier(ident)) {
+      return loadFromPathIdentifier((PathIdentifier) ident);
+    }
+
+    try {
+      return Pair.of(icebergCatalog.loadTable(buildIdentifier(ident)), null);
+
+    } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
+      // if the original load didn't work, the identifier may be extended and 
include a snapshot selector
+      TableIdentifier namespaceAsIdent = 
buildIdentifier(namespaceToIdentifier(ident.namespace()));

Review comment:
       I forgot one other thing. This is a more reasonable change if we do it 
in Spark because `SparkTable` is a pretty thin wrapper around Iceberg's 
`Table`. If we do this in core, then we would have to update `BaseTable` to 
select a version -- which is pretty strange with the API -- or to introduce a 
wrapper table type that only allows reading. So since we already have the 
wrapper table it seemed easiest just to update that for now and not 
over-complicate the core Table API.




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

Reply via email to