dimas-b commented on code in PR #4724:
URL: https://github.com/apache/polaris/pull/4724#discussion_r3417983732
##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -1415,8 +1416,14 @@ public void renameView(RenameTableRequest request) {
TableMetadata filteredMetadata =
metadata.removeSnapshotsIf(s ->
!referencedSnapshotIds.contains(s.snapshotId()));
+ TableMetadata filteredMetadataWithLocation =
+ TableMetadata.buildFrom(filteredMetadata)
Review Comment:
`removeSnapshotsIf()` uses a `Builder`... so why rebuild twice? Why not
inline the code from `metadata.removeSnapshotsIf()` and reuse the same build
both for filtering and resetting metadata location?
I guess it's also be more efficient by _not_ constructing two useless lists:
`List<Snapshot>` and `Set<Long>` 🤔
##########
runtime/service/src/test/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandlerTest.java:
##########
@@ -296,4 +304,44 @@ void loadCredentialsFallsBackWhenEntityLocationMissing() {
assertThat(c.config()).containsExactlyInAnyOrderEntriesOf(fakeCredentials);
});
}
+
+ @Test
+ void filterResponseToSnapshotsRefsPreservesMetadataLocation() throws
Exception {
+ try (InMemoryCatalog catalog = new InMemoryCatalog()) {
+ catalog.initialize("test", Map.of());
+ catalog.createNamespace(NS1);
+ Schema schema = new Schema(Types.NestedField.required(1, "id",
Types.IntegerType.get()));
+ Table table = catalog.createTable(TABLE2, schema);
+
table.newFastAppend().appendFile(dataFile("file:/tmp/data/f1.parquet")).commit();
+
table.newFastAppend().appendFile(dataFile("file:/tmp/data/f2.parquet")).commit();
+
+ TableMetadata metadata = ((BaseTable)
catalog.loadTable(TABLE2)).operations().current();
+ assertThat(metadata.snapshots()).hasSize(2);
Review Comment:
Why not build a test `TableMetadata` directly in this method? Why bother
with `InMemoryCatalog`?
--
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]