You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "rdblue (via GitHub)" <gi...@apache.org> on 2023/07/03 20:51:23 UTC

[GitHub] [iceberg] rdblue commented on a diff in pull request #6512: Core: Support registerTable with REST session catalog

rdblue commented on code in PR #6512:
URL: https://github.com/apache/iceberg/pull/6512#discussion_r1251273788


##########
core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java:
##########
@@ -2615,6 +2616,100 @@ public void tableCreationWithoutNamespace() {
         .hasMessageContaining("Namespace does not exist: non-existing");
   }
 
+  @Test
+  public void testRegisterTable() {
+    C catalog = catalog();
+
+    if (requiresNamespaceCreate()) {
+      catalog.createNamespace(TABLE.namespace());
+    }
+
+    Map<String, String> properties =
+        ImmutableMap.of("user", "someone", "created-at", "2023-01-15T00:00:01");
+    Table table =
+        catalog
+            .buildTable(TABLE, SCHEMA)
+            .withPartitionSpec(SPEC)
+            .withSortOrder(WRITE_ORDER)
+            .withProperties(properties)
+            .create();
+
+    table.newFastAppend().appendFile(FILE_A).commit();
+    table.newFastAppend().appendFile(FILE_B).commit();
+    table.newDelete().deleteFile(FILE_A).commit();
+    table.newFastAppend().appendFile(FILE_C).commit();
+
+    TableOperations ops = ((HasTableOperations) table).operations();
+    String metadataLocation = ops.current().metadataFileLocation();
+
+    catalog.dropTable(TABLE, false);
+
+    Table registeredTable = catalog.registerTable(TABLE, metadataLocation);
+    Assertions.assertThat(registeredTable).isNotNull();
+
+    TableOperations registeredTableOps = ((HasTableOperations) table).operations();
+    Assertions.assertThat(metadataLocation)
+        .isEqualTo(registeredTableOps.current().metadataFileLocation());

Review Comment:
   I don't think that register table should be required to use the same metadata file. Some metadata may be overridden so there's no guarantee it's the same file.



-- 
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-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org