RussellSpitzer commented on code in PR #12228:
URL: https://github.com/apache/iceberg/pull/12228#discussion_r2078343298


##########
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:
   In fact why aren't we checking if the T2 object matches the "registered" 
table? Shouldn't they just be completely identical?



-- 
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]

Reply via email to