coded9 commented on code in PR #13143:
URL: https://github.com/apache/iceberg/pull/13143#discussion_r2450450779


##########
core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java:
##########
@@ -959,6 +966,35 @@ public void testLoadMissingTable() {
         .hasMessageStartingWith("Table does not exist: ns.tbl");
   }
 
+  @Test
+  public void testLoadTableWithMissingMetadatafile(@TempDir Path tempDir) 
throws IOException {

Review Comment:
   Addressed



##########
core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java:
##########
@@ -959,6 +966,35 @@ public void testLoadMissingTable() {
         .hasMessageStartingWith("Table does not exist: ns.tbl");
   }
 
+  @Test
+  public void testLoadTableWithMissingMetadatafile(@TempDir Path tempDir) 
throws IOException {
+    C catalog = catalog();
+
+    if (requiresNamespaceCreate()) {
+      catalog.createNamespace(TBL.namespace());
+    }
+
+    catalog.buildTable(TBL, SCHEMA).create();
+    assertThat(catalog.tableExists(TBL)).as("Table should exist").isTrue();
+
+    Table table = catalog.loadTable(TBL);
+    String metadataFileLocation =
+        ((HasTableOperations) 
table).operations().current().metadataFileLocation();
+    Path renamedMetadataFile = tempDir.resolve("tmp.json");
+    renamedMetadataFile.toFile().deleteOnExit();
+    Files.writeString(renamedMetadataFile, "metadata");
+    Path metadataFilePath =
+        metadataFileLocation.startsWith("file:")
+            ? Paths.get(URI.create(metadataFileLocation))
+            : Paths.get(metadataFileLocation);
+    Files.move(metadataFilePath, renamedMetadataFile, 
StandardCopyOption.REPLACE_EXISTING);
+
+    assertThatThrownBy(() -> catalog.loadTable(TBL))
+        .isInstanceOf(NotFoundException.class)
+        .hasMessageContaining("Failed to open input stream for file: " + 
metadataFileLocation);
+    Files.move(renamedMetadataFile, metadataFilePath, 
StandardCopyOption.REPLACE_EXISTING);

Review Comment:
   Done



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