This is an automated email from the ASF dual-hosted git repository.
honahx pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-python.git
The following commit(s) were added to refs/heads/main by this push:
new c5735dc raise exception if namespace does not exist in
load_namespace_properties (#477)
c5735dc is described below
commit c5735dc6cffb133abb1465f12a1d37097c277431
Author: Rushil Shah <[email protected]>
AuthorDate: Tue Feb 27 12:56:43 2024 -0500
raise exception if namespace does not exist in load_namespace_properties
(#477)
---
pyiceberg/catalog/sql.py | 4 +++-
tests/catalog/test_sql.py | 12 ++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/pyiceberg/catalog/sql.py b/pyiceberg/catalog/sql.py
index 0059da6..b6b2fee 100644
--- a/pyiceberg/catalog/sql.py
+++ b/pyiceberg/catalog/sql.py
@@ -567,7 +567,9 @@ class SqlCatalog(Catalog):
Raises:
NoSuchNamespaceError: If a namespace with the given name does not
exist.
"""
- database_name = self.identifier_to_database(namespace,
NoSuchNamespaceError)
+ database_name = self.identifier_to_database(namespace)
+ if not self._namespace_exists(database_name):
+ raise NoSuchNamespaceError(f"Database {database_name} does not
exists")
stmt = select(IcebergNamespaceProperties).where(
IcebergNamespaceProperties.catalog_name == self.name,
IcebergNamespaceProperties.namespace == database_name
diff --git a/tests/catalog/test_sql.py b/tests/catalog/test_sql.py
index bc75eb6..2b1167f 100644
--- a/tests/catalog/test_sql.py
+++ b/tests/catalog/test_sql.py
@@ -726,6 +726,18 @@ def test_load_empty_namespace_properties(catalog:
SqlCatalog, database_name: str
assert listed_properties == {"exists": "true"}
[email protected](
+ 'catalog',
+ [
+ lazy_fixture('catalog_memory'),
+ lazy_fixture('catalog_sqlite'),
+ ],
+)
+def test_load_namespace_properties_non_existing_namespace(catalog: SqlCatalog)
-> None:
+ with pytest.raises(NoSuchNamespaceError):
+ catalog.load_namespace_properties("does_not_exist")
+
+
@pytest.mark.parametrize(
'catalog',
[