RussellSpitzer commented on code in PR #12228: URL: https://github.com/apache/iceberg/pull/12228#discussion_r2078341793
########## core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java: ########## @@ -3163,9 +3170,107 @@ public void testRegisterExistingTable() { assertThatThrownBy(() -> catalog.registerTable(identifier, metadataLocation)) .isInstanceOf(AlreadyExistsException.class) .hasMessageStartingWith("Table already exists: a.t1"); + assertThatThrownBy(() -> catalog.registerTable(identifier, metadataLocation, false)) + .isInstanceOf(AlreadyExistsException.class) + .hasMessageStartingWith("Table already exists: a.t1"); assertThat(catalog.dropTable(identifier)).isTrue(); } + @Test + public void testRegisterAndOverwriteForeignTable() { + C catalog = catalog(); + + TableIdentifier identT1 = TableIdentifier.of("a", "t1"); + TableIdentifier identT2 = TableIdentifier.of("a", "t2"); + + if (requiresNamespaceCreate()) { + catalog.createNamespace(identT1.namespace()); + } + + Table t1 = catalog.createTable(identT1, SCHEMA); + UUID t1UUID = t1.uuid(); + Table t2 = + catalog.createTable( + identT2, SCHEMA, PartitionSpec.builderFor(SCHEMA).bucket("id", 16).build()); + assertThat(t1.spec().isPartitioned()).isFalse(); + assertThat(t2.spec().isPartitioned()).isTrue(); + + TableOperations opsT2 = operation(t2); + + // register table t1 with metadata from table t2 + Table registered = catalog.registerTable(identT1, opsT2.current().metadataFileLocation(), true); + + assertThat(registered.uuid()) Review Comment: We can just check that it matches t2 uuid rather than checking it doesn't match t1. -- 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