You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/10/07 00:49:55 UTC

[GitHub] [iceberg] flyrain commented on a diff in pull request #5740: Spark 3.3: Add SparkChangelogTable

flyrain commented on code in PR #5740:
URL: https://github.com/apache/iceberg/pull/5740#discussion_r989584315


##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/SparkCatalog.java:
##########
@@ -605,19 +620,27 @@ private Pair<Table, Long> load(Identifier ident) {
       }
 
       // loading the namespace as a table worked, check the name to see if it is a valid selector
+      // or if the name points to the changelog
+
+      if (ident.name().equalsIgnoreCase(SparkChangelogTable.TABLE_NAME)) {
+        return new SparkChangelogTable(table, !cacheEnabled);
+      }
+
       Matcher at = AT_TIMESTAMP.matcher(ident.name());
       if (at.matches()) {
         long asOfTimestamp = Long.parseLong(at.group(1));
-        return Pair.of(table, SnapshotUtil.snapshotIdAsOfTime(table, asOfTimestamp));
+        long snapshotId = SnapshotUtil.snapshotIdAsOfTime(table, asOfTimestamp);
+        return new SparkTable(table, snapshotId, !cacheEnabled);
       }
 
       Matcher id = SNAPSHOT_ID.matcher(ident.name());
       if (id.matches()) {
         long snapshotId = Long.parseLong(id.group(1));
-        return Pair.of(table, snapshotId);
+        return new SparkTable(table, snapshotId, !cacheEnabled);
       }

Review Comment:
   Not a blocker. It'd be more readable if we wrap the code within the catch clause. like this:
   ```
    try {
         org.apache.iceberg.Table table = icebergCatalog.loadTable(buildIdentifier(ident));
         return new SparkTable(table, !cacheEnabled);
       } catch (org.apache.iceberg.exceptions.NoSuchTableException e) {
           Table table = loadAlternativeTable(ident, e);
           if (table != null) {
             return table;
           } else {
             throw e;
           }
      }
   ```



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org