flyrain commented on code in PR #5116:
URL: https://github.com/apache/polaris/pull/5116#discussion_r3617706763
##########
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.
Review Comment:
Nit: I think we should just call out the reason behind the current behavior.
##########
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:
Do we need to set it given `suppressHistoricalSnapshots` is used here?
--
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]