diff --git a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java index ae42c5ae5c..e76aa32f74 100644 --- a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java +++ b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java @@ -36,12 +36,7 @@ import java.lang.reflect.Method; import java.net.URI; import java.nio.file.Path; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import java.util.stream.Stream; import org.apache.hadoop.conf.Configuration; import org.apache.iceberg.BaseTable; @@ -563,6 +558,16 @@ public void testCreateTableWithOverriddenBaseLocationCannotOverlapSibling() { .hasMessageContaining("because it conflicts with existing table or namespace"); } + @Test + public void testCreateTableWithMetadataConflictingName() { + Catalog catalog = managementApi.getCatalog(currentCatalogName); + restCatalog.createNamespace(Namespace.of("ns1")); + TableIdentifier tableIdentifier = TableIdentifier.of("ns1", "history"); + restCatalog.buildTable(tableIdentifier, SCHEMA).withProperty("stage-create", "true").create(); + Table table = restCatalog.loadTable(tableIdentifier); + assertThat(table).isNotNull().isInstanceOf(BaseTable.class); + } + @Test public void testCreateTableWithOverriddenBaseLocationMustResideInNsDirectory() { Catalog catalog = managementApi.getCatalog(currentCatalogName); diff --git a/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java b/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java index ba9df38c96..6098b61c2b 100644 --- a/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java +++ b/service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java @@ -212,6 +212,14 @@ public IcebergCatalog( this.polarisEventListener = polarisEventListener; } + @Override + public boolean tableExists(TableIdentifier identifier) { + if (isValidIdentifier(identifier)) { + return newTableOps(identifier).current() != null; + } + return false; + } + @Override public String name() { return catalogName;