Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions itests/test-docker/k8s/hive-metastore/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ data:
<name>metastore.catalog.servlet.auth</name>
<value>none</value>
</property>
<property>
<name>metastore.iceberg.catalog.unique.table.location</name>
<value>true</value>
</property>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -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<RESTCatalog> {
private static HiveIcebergRESTCatalogClient client;
Expand Down Expand Up @@ -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.
*
* <p>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);
}
}
Loading