The base Iceberg test moves the metadata file with {@code Files.move()} which only works + * on a local disk. Docker tests store data on S3, so this override deletes the file. + */ + @Test + @Override + public void testLoadTableWithMissingMetadataFile(@TempDir java.nio.file.Path tempDir) + throws IOException { + RESTCatalog 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(); + table.io().deleteFile(metadataFileLocation); + + assertThatThrownBy(() -> catalog.loadTable(TBL)) + .isInstanceOf(NotFoundException.class) + .hasMessageContaining("Failed to open input stream for file: " + metadataFileLocation); + } }