adnanhemani commented on code in PR #5116:
URL: https://github.com/apache/polaris/pull/5116#discussion_r3626778756


##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -1693,20 +1692,25 @@ public void renameView(RenameTableRequest request) {
     catalogHandlerUtils().renameView(viewCatalog, request);
   }
 
-  private @NonNull LoadTableResponse filterResponseToSnapshots(
+  @VisibleForTesting
+  @NonNull LoadTableResponse filterResponseToSnapshots(
       LoadTableResponse loadTableResponse, String snapshots) {
     if (snapshots == null || snapshots.equalsIgnoreCase(SNAPSHOTS_ALL)) {
       return loadTableResponse;
     } else if (snapshots.equalsIgnoreCase(SNAPSHOTS_REFS)) {
       TableMetadata metadata = loadTableResponse.tableMetadata();
 
-      Set<Long> referencedSnapshotIds =
-          metadata.refs().values().stream()
-              .map(SnapshotRef::snapshotId)
-              .collect(Collectors.toSet());
-
+      // suppressHistoricalSnapshots() drops snapshots not referenced by any 
branch/tag without
+      // recording a MetadataUpdate, so metadataLocation() survives the 
filter. This mirrors
+      // org.apache.iceberg.rest.CatalogHandlers#loadTable's REFS case in 
Iceberg core; using
+      // removeSnapshotsIf() here instead would record a change and force 
metadataLocation() to
+      // null (TableMetadata requires an empty change list to claim a 
persisted location), even
+      // though nothing was actually written to disk.
       TableMetadata filteredMetadata =
-          metadata.removeSnapshotsIf(s -> 
!referencedSnapshotIds.contains(s.snapshotId()));
+          TableMetadata.buildFrom(metadata)
+              .withMetadataLocation(metadata.metadataFileLocation())

Review Comment:
   Don't think we can ignore it: 
https://github.com/apache/iceberg/blob/apache-iceberg-1.11.0/core/src/main/java/org/apache/iceberg/TableMetadata.java#L974-L1011
   
   Per this, I think we need to manually set it, so this is correct.



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

Reply via email to