@@ -543,19 +543,21 @@ def drop_namespace(self, namespace: Union[str, Identifier]) -> None:
543543 NoSuchNamespaceError: If a namespace with the given name does not exist.
544544 NamespaceNotEmptyError: If the namespace is not empty.
545545 """
546- if self ._namespace_exists (namespace ):
547- namespace_str = Catalog .namespace_to_string (namespace )
548- if tables := self .list_tables (namespace ):
549- raise NamespaceNotEmptyError (f"Namespace { namespace_str } is not empty. { len (tables )} tables exist." )
550-
551- with Session (self .engine ) as session :
552- session .execute (
553- delete (IcebergNamespaceProperties ).where (
554- IcebergNamespaceProperties .catalog_name == self .name ,
555- IcebergNamespaceProperties .namespace == namespace_str ,
556- )
546+ if not self ._namespace_exists (namespace ):
547+ raise NoSuchNamespaceError (f"Namespace does not exist: { namespace } " )
548+
549+ namespace_str = Catalog .namespace_to_string (namespace )
550+ if tables := self .list_tables (namespace ):
551+ raise NamespaceNotEmptyError (f"Namespace { namespace_str } is not empty. { len (tables )} tables exist." )
552+
553+ with Session (self .engine ) as session :
554+ session .execute (
555+ delete (IcebergNamespaceProperties ).where (
556+ IcebergNamespaceProperties .catalog_name == self .name ,
557+ IcebergNamespaceProperties .namespace == namespace_str ,
557558 )
558- session .commit ()
559+ )
560+ session .commit ()
559561
560562 def list_tables (self , namespace : Union [str , Identifier ]) -> List [Identifier ]:
561563 """List tables under the given namespace in the catalog.
0 commit comments