kevinjqliu commented on code in PR #2955:
URL: https://github.com/apache/iceberg-python/pull/2955#discussion_r2729880403
##########
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:
do you know why theres a behavior difference here?
ideally we're testing for consistent catalog behaviors in this class
##########
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:
should we just add `namespace_exists` to all the catalog implementations?
similar to the one in the rest catalog,
https://github.com/apache/iceberg-python/blob/2f293d6d3de79a85143f71e1674738756abcdb91/pyiceberg/catalog/rest/__init__.py#L1106-L1131
--
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]