nastra commented on code in PR #11643: URL: https://github.com/apache/iceberg/pull/11643#discussion_r1856133107
########## core/src/test/java/org/apache/iceberg/hadoop/TestHadoopCatalog.java: ########## @@ -548,6 +549,32 @@ public void testVersionHintFileMissingMetadata() throws Exception { .hasMessageStartingWith("Table does not exist"); } + @Test + public void testMetadataFileMissing() throws Exception { + addVersionsToTable(table); + + HadoopTableOperations tableOperations = + (HadoopTableOperations) TABLES.newTableOps(tableLocation); + + FileIO io = table.io(); + io.deleteFile(versionHintFile.getPath()); + try (PositionOutputStream stream = io.newOutputFile(versionHintFile.getPath()).create()) { + stream.write("3".getBytes(StandardCharsets.UTF_8)); + } + + // Check the result of the findVersion(), and load the table and check the current snapshotId + assertThat(tableOperations.findVersion()).isEqualTo(3); + assertThat(TABLES.load(tableLocation).currentSnapshot().snapshotId()) + .isEqualTo(table.currentSnapshot().snapshotId()); + + io.deleteFile(tableOperations.getMetadataFile(3).toString()); + assertThatThrownBy(() -> TABLES.load(tableLocation)) + .isInstanceOf(ValidationException.class) + .hasMessage( + "Metadata file for version 3 is missing under " + + (new Path(tableLocation, "metadata"))); Review Comment: what about `metadataDir.toPath().toString()`? -- 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