You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by et...@apache.org on 2025/01/20 10:51:18 UTC

(iceberg) branch main updated: Core: List namespaces/tables when testing identifier with a dot (#11991)

This is an automated email from the ASF dual-hosted git repository.

etudenhoefner pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git


The following commit(s) were added to refs/heads/main by this push:
     new 41b458b702 Core: List namespaces/tables when testing identifier with a dot (#11991)
41b458b702 is described below

commit 41b458b7022c7b0cd78eeca9102392db7889d3c9
Author: Eduard Tudenhoefner <et...@gmail.com>
AuthorDate: Mon Jan 20 11:51:12 2025 +0100

    Core: List namespaces/tables when testing identifier with a dot (#11991)
---
 .../java/org/apache/iceberg/catalog/CatalogTests.java    | 16 ++++++++++------
 .../java/org/apache/iceberg/jdbc/TestJdbcCatalog.java    |  6 ++++++
 .../apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java |  5 +++--
 .../iceberg/rest/RESTCompatibilityKitCatalogTests.java   |  7 +++++++
 .../apache/iceberg/rest/RESTCompatibilityKitSuite.java   |  1 +
 5 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java b/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
index 51d3cbb933..58b67e953f 100644
--- a/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
+++ b/core/src/test/java/org/apache/iceberg/catalog/CatalogTests.java
@@ -244,7 +244,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
     assertThatThrownBy(() -> catalog.loadNamespaceMetadata(NS))
         .isInstanceOf(NoSuchNamespaceException.class)
-        .hasMessageStartingWith("Namespace does not exist: newdb");
+        .hasMessageStartingWith("Namespace does not exist: %s", NS);
 
     catalog.createNamespace(NS);
     assertThat(catalog.namespaceExists(NS)).as("Namespace should exist").isTrue();
@@ -331,7 +331,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
     assertThatThrownBy(() -> catalog.setProperties(NS, ImmutableMap.of("test", "value")))
         .isInstanceOf(NoSuchNamespaceException.class)
-        .hasMessageStartingWith("Namespace does not exist: newdb");
+        .hasMessageStartingWith("Namespace does not exist: %s", NS);
   }
 
   @Test
@@ -363,7 +363,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
     assertThatThrownBy(() -> catalog.removeProperties(NS, ImmutableSet.of("a", "b")))
         .isInstanceOf(NoSuchNamespaceException.class)
-        .hasMessageStartingWith("Namespace does not exist: newdb");
+        .hasMessageStartingWith("Namespace does not exist: %s", NS);
   }
 
   @Test
@@ -499,6 +499,8 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
     catalog.createNamespace(withDot);
     assertThat(catalog.namespaceExists(withDot)).as("Namespace should exist").isTrue();
 
+    assertThat(catalog.listNamespaces()).contains(withDot);
+
     Map<String, String> properties = catalog.loadNamespaceMetadata(withDot);
     assertThat(properties).as("Properties should be accessible").isNotNull();
     assertThat(catalog.dropNamespace(withDot)).as("Dropping the namespace should succeed").isTrue();
@@ -565,15 +567,17 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
     C catalog = catalog();
 
-    TableIdentifier ident = TableIdentifier.of("ns", "ta.ble");
+    Namespace namespace = Namespace.of("ns");
+    TableIdentifier ident = TableIdentifier.of(namespace, "ta.ble");
     if (requiresNamespaceCreate()) {
-      catalog.createNamespace(Namespace.of("ns"));
+      catalog.createNamespace(namespace);
     }
 
     assertThat(catalog.tableExists(ident)).as("Table should not exist").isFalse();
 
     catalog.buildTable(ident, SCHEMA).create();
     assertThat(catalog.tableExists(ident)).as("Table should exist").isTrue();
+    assertThat(catalog.listTables(namespace)).contains(ident);
 
     Table loaded = catalog.loadTable(ident);
     assertThat(loaded.schema().asStruct())
@@ -2280,7 +2284,7 @@ public abstract class CatalogTests<C extends Catalog & SupportsNamespaces> {
 
     assertThatThrownBy(() -> catalog.buildTable(TABLE, SCHEMA).replaceTransaction())
         .isInstanceOf(NoSuchTableException.class)
-        .hasMessageStartingWith("Table does not exist: newdb.table");
+        .hasMessageStartingWith("Table does not exist: %s", TABLE);
   }
 
   @Test
diff --git a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
index a1363ac508..132d36cdab 100644
--- a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
+++ b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalog.java
@@ -112,6 +112,12 @@ public class TestJdbcCatalog extends CatalogTests<JdbcCatalog> {
     return true;
   }
 
+  @Override
+  protected boolean supportsNamesWithDot() {
+    // namespaces with a dot are not supported
+    return false;
+  }
+
   protected List<String> metadataVersionFiles(String location) {
     return Stream.of(new File(location).listFiles())
         .filter(file -> !file.isDirectory())
diff --git a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java
index 7586d880c1..74e3d6bc52 100644
--- a/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java
+++ b/core/src/test/java/org/apache/iceberg/jdbc/TestJdbcCatalogWithV1Schema.java
@@ -58,8 +58,9 @@ public class TestJdbcCatalogWithV1Schema extends CatalogTests<JdbcCatalog> {
   }
 
   @Override
-  protected boolean supportsNamespaceProperties() {
-    return true;
+  protected boolean supportsNamesWithDot() {
+    // namespaces with a dot are not supported
+    return false;
   }
 
   @Override
diff --git a/open-api/src/test/java/org/apache/iceberg/rest/RESTCompatibilityKitCatalogTests.java b/open-api/src/test/java/org/apache/iceberg/rest/RESTCompatibilityKitCatalogTests.java
index a709d81434..87ec90663d 100644
--- a/open-api/src/test/java/org/apache/iceberg/rest/RESTCompatibilityKitCatalogTests.java
+++ b/open-api/src/test/java/org/apache/iceberg/rest/RESTCompatibilityKitCatalogTests.java
@@ -90,4 +90,11 @@ public class RESTCompatibilityKitCatalogTests extends CatalogTests<RESTCatalog>
         RESTCompatibilityKitSuite.RCK_OVERRIDES_REQUESTED_LOCATION,
         false);
   }
+
+  @Override
+  protected boolean supportsNamesWithDot() {
+    // underlying JDBC catalog doesn't support namespaces with a dot
+    return PropertyUtil.propertyAsBoolean(
+        restCatalog.properties(), RESTCompatibilityKitSuite.RCK_SUPPORTS_NAMES_WITH_DOT, false);
+  }
 }
diff --git a/open-api/src/test/java/org/apache/iceberg/rest/RESTCompatibilityKitSuite.java b/open-api/src/test/java/org/apache/iceberg/rest/RESTCompatibilityKitSuite.java
index a7bbe64c06..a153d48b8c 100644
--- a/open-api/src/test/java/org/apache/iceberg/rest/RESTCompatibilityKitSuite.java
+++ b/open-api/src/test/java/org/apache/iceberg/rest/RESTCompatibilityKitSuite.java
@@ -40,6 +40,7 @@ public class RESTCompatibilityKitSuite {
   static final String RCK_REQUIRES_NAMESPACE_CREATE = "rck.requires-namespace-create";
   static final String RCK_SUPPORTS_SERVERSIDE_RETRY = "rck.supports-serverside-retry";
   static final String RCK_OVERRIDES_REQUESTED_LOCATION = "rck.overrides-requested-location";
+  static final String RCK_SUPPORTS_NAMES_WITH_DOT = "rck.supports-names-with-dot";
 
   protected RESTCompatibilityKitSuite() {}
 }