dramaticlly commented on code in PR #12228:
URL: https://github.com/apache/iceberg/pull/12228#discussion_r2078360689
##########
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())
+ .as("table UUID should differ when registering with foreign metadata")
+ .isNotEqualTo(t1UUID);
+ assertThat(registered.spec().isPartitioned())
+ .as("table is expected to be partitioned after registration with t2’s
metadata")
+ .isEqualTo(t2.spec().isPartitioned())
+ .isTrue();
+ assertThat(operation(registered).refresh())
+ .usingRecursiveComparison()
+ // Nessie catalog holds different Nessie commit-ID from which the
metadata has been loaded.
Review Comment:
yeah I agree, but since CatalogTests is abstract and existing
TestNessieCatalog implements this require exclusion on some of the table
properties. Do you think I shall add a assumeTrue to exclude Nessies from this
test instead?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]