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


##########
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:
   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.  The spec supports 
hierarchical namespaces, so that seems to be working as intended.
   
   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