amogh-jahagirdar commented on code in PR #11779: URL: https://github.com/apache/iceberg/pull/11779#discussion_r1896074073
########## core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java: ########## @@ -2418,6 +2421,34 @@ public void testPaginationForListTables(int numberOfItems) { eq(ListTablesResponse.class)); } + @Test + public void testReplaceTableKeepsSnapshotLog() { Review Comment: Could we put this test in `CatalogTests`? That'll cover both REST + non-REST cases (TestRESTCatalog extends `CatalogTests`). ########## core/src/test/java/org/apache/iceberg/rest/TestRESTCatalog.java: ########## @@ -2418,6 +2421,34 @@ public void testPaginationForListTables(int numberOfItems) { eq(ListTablesResponse.class)); } + @Test + public void testReplaceTableKeepsSnapshotLog() { + RESTCatalogAdapter adapter = Mockito.spy(new RESTCatalogAdapter(backendCatalog)); + RESTCatalog catalog = catalog(adapter); + + if (requiresNamespaceCreate()) { + catalog.createNamespace(TABLE.namespace()); + } + + catalog.createTable(TABLE, SCHEMA); + + Table table = catalog.loadTable(TABLE); + table.newAppend().appendFile(FILE_A).commit(); + + List<HistoryEntry> snapshotLogBeforeReplace = + ((BaseTable) table).operations().current().snapshotLog(); + assertThat(snapshotLogBeforeReplace).hasSize(1); + + Transaction replaceTableTransaction = catalog.newReplaceTableTransaction(TABLE, SCHEMA, false); + replaceTableTransaction.newAppend().appendFile(FILE_A).commit(); + replaceTableTransaction.commitTransaction(); + + table.refresh(); + assertThat(((BaseTable) table).operations().current().snapshotLog()) + .hasSize(2) + .containsAll(snapshotLogBeforeReplace); Review Comment: Could we assert the exact snapshot log contents instead of just doing a containsAll check? We should have both the log before the replace and the new snapshot produced as part of the replace. -- 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