nastra commented on code in PR #10755: URL: https://github.com/apache/iceberg/pull/10755#discussion_r1837955891
########## core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java: ########## @@ -1284,6 +1284,35 @@ public void testUpdateTableSpecThenRevert() { assertThat(table.spec()).as("Loaded table should have expected spec").isEqualTo(TABLE_SPEC); } + @Test + public void testRemoveUnusedSpec() { + C catalog = catalog(); + + if (requiresNamespaceCreate()) { + catalog.createNamespace(NS); + } + + Table table = + catalog + .buildTable(TABLE, SCHEMA) + .withPartitionSpec(SPEC) + .withProperty(TableProperties.GC_ENABLED, "true") + .create(); + PartitionSpec spec = table.spec(); + // added some file to trigger expire snapshot + table.newFastAppend().appendFile(FILE_A).commit(); + table.updateSpec().addField(Expressions.bucket("data", 16)).commit(); + table.updateSpec().removeField(Expressions.bucket("data", 16)).commit(); + table.updateSpec().addField("data").commit(); + assertThat(table.specs().size()).as("Should have 3 total specs").isEqualTo(3); + PartitionSpec current = table.spec(); + table.expireSnapshots().cleanExpiredMeta(true).commit(); + + Table loaded = catalog.loadTable(TABLE); + assertThat(loaded.specs().values()) + .hasSameElementsAs(Lists.asList(spec, current, new PartitionSpec[0])); Review Comment: containsExactly(..) -- 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-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org