diff --git a/itests/test-docker/k8s/hive-metastore/configmap.yaml b/itests/test-docker/k8s/hive-metastore/configmap.yaml index 72d0ce44762e..625008518ae0 100644 --- a/itests/test-docker/k8s/hive-metastore/configmap.yaml +++ b/itests/test-docker/k8s/hive-metastore/configmap.yaml @@ -41,4 +41,8 @@ data: metastore.catalog.servlet.auth none + + metastore.iceberg.catalog.unique.table.location + true + diff --git a/itests/test-docker/src/test/java/org/apache/iceberg/rest/HiveIcebergRESTCatalogTests.java b/itests/test-docker/src/test/java/org/apache/iceberg/rest/HiveIcebergRESTCatalogTests.java index 680ef9b5758f..671f3d510ed6 100644 --- a/itests/test-docker/src/test/java/org/apache/iceberg/rest/HiveIcebergRESTCatalogTests.java +++ b/itests/test-docker/src/test/java/org/apache/iceberg/rest/HiveIcebergRESTCatalogTests.java @@ -18,12 +18,19 @@ package org.apache.iceberg.rest; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import java.io.IOException; import java.util.Map; +import org.apache.iceberg.HasTableOperations; +import org.apache.iceberg.Table; import org.apache.iceberg.catalog.CatalogTests; +import org.apache.iceberg.exceptions.NotFoundException; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; class HiveIcebergRESTCatalogTests extends CatalogTests { private static HiveIcebergRESTCatalogClient client; @@ -75,4 +82,33 @@ protected boolean supportsNamesWithSlashes() { protected boolean supportsServerSideRetry() { return true; } + + /** + * Checks that loading a table fails clearly when its metadata file is missing. + * + *

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); + } }