rambleraptor commented on code in PR #2955:
URL: https://github.com/apache/iceberg-python/pull/2955#discussion_r2730210107


##########
tests/integration/test_catalog.py:
##########
@@ -635,3 +636,141 @@ def test_rest_custom_namespace_separator(rest_catalog: 
RestCatalog, table_schema
 
     loaded_table = 
rest_catalog.load_table(identifier=full_table_identifier_tuple)
     assert loaded_table.name() == full_table_identifier_tuple
+
+
+def _namespace_exists(catalog: Catalog, namespace: str | Identifier) -> bool:
+    try:
+        catalog.load_namespace_properties(namespace)
+        return True
+    except NoSuchNamespaceError:
+        return False

Review Comment:
   Yeah, I agree 100% with this. I created #2969. I can make a separate PR, but 
I feel like it'll potentially muddy this one to add it here. How does that 
sound?



##########
tests/integration/test_catalog.py:
##########
@@ -635,3 +636,141 @@ def test_rest_custom_namespace_separator(rest_catalog: 
RestCatalog, table_schema
 
     loaded_table = 
rest_catalog.load_table(identifier=full_table_identifier_tuple)
     assert loaded_table.name() == full_table_identifier_tuple
+
+
+def _namespace_exists(catalog: Catalog, namespace: str | Identifier) -> bool:
+    try:
+        catalog.load_namespace_properties(namespace)
+        return True
+    except NoSuchNamespaceError:
+        return False
+
+
[email protected]
[email protected]("test_catalog", CATALOGS)
+def test_namespace_with_slash(test_catalog: Catalog) -> None:
+    if isinstance(test_catalog, HiveCatalog):
+        pytest.skip(f"{type(test_catalog).__name__} does not support slash in 
namespace")
+
+    namespace = ("new/db",)
+
+    if _namespace_exists(test_catalog, namespace):
+        test_catalog.drop_namespace(namespace)
+
+    assert not _namespace_exists(test_catalog, namespace)
+
+    test_catalog.create_namespace(namespace)
+    assert _namespace_exists(test_catalog, namespace)
+
+    properties = test_catalog.load_namespace_properties(namespace)
+    assert properties is not None
+
+    test_catalog.drop_namespace(namespace)
+    assert not _namespace_exists(test_catalog, namespace)
+
+
[email protected]
[email protected]("test_catalog", CATALOGS)
+def test_namespace_with_dot(test_catalog: Catalog) -> None:
+    if isinstance(test_catalog, (HiveCatalog, SqlCatalog)):
+        pytest.skip(f"{type(test_catalog).__name__} does not support dot in 
namespace")
+
+    namespace = ("new.db",)
+
+    if _namespace_exists(test_catalog, namespace):
+        test_catalog.drop_namespace(namespace)
+
+    assert not _namespace_exists(test_catalog, namespace)
+
+    test_catalog.create_namespace(namespace)
+    assert _namespace_exists(test_catalog, namespace)
+
+    # list_namespaces returns a list of tuples
+    if isinstance(test_catalog, RestCatalog):
+        namespaces = test_catalog.list_namespaces()
+        assert ("new",) in namespaces or ("new.db",) in namespaces
+    else:
+        assert namespace in test_catalog.list_namespaces()

Review Comment:
   I didn't think of this as an actual issue, but maybe it is.
   
   Calling list namespaces would get you:
   
   ------------------------
   | rest_catalog |  new      |
   | others           |  new.db |
   -------------------------
   
   That's because `iceberg-rest-fixture` treats this as hierarchical 
namespaces, which many other catalogs don't support. 
   
   My comment was very poor, so I wrote an actual comment to explain this.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to