@@ -175,7 +175,7 @@ def create_table(
175175
176176 database_name , table_name = self .identifier_to_database_and_table (identifier )
177177 if not self ._namespace_exists (database_name ):
178- raise NoSuchNamespaceError ( f"Namespace does not exist: { database_name } " )
178+ self . create_namespace ( database_name )
179179
180180 location = self ._resolve_table_location (location , database_name , table_name )
181181 metadata_location = self ._get_metadata_location (location = location )
@@ -263,7 +263,7 @@ def load_table(self, identifier: Union[str, Identifier]) -> Table:
263263 result = session .scalar (stmt )
264264 if result :
265265 return self ._convert_orm_to_iceberg (result )
266- raise NoSuchTableError (f"Table does not exist: { database_name } . { table_name } " )
266+ raise NoSuchTableError (f"Table does not exist: { identifier_tuple } " )
267267
268268 def drop_table (self , identifier : Union [str , Identifier ]) -> None :
269269 """Drop a table.
@@ -286,7 +286,7 @@ def drop_table(self, identifier: Union[str, Identifier]) -> None:
286286 )
287287 )
288288 if res .rowcount < 1 :
289- raise NoSuchTableError (f"Table does not exist: { database_name } . { table_name } " )
289+ raise NoSuchTableError (f"Table does not exist: { identifier_tuple } " )
290290 else :
291291 try :
292292 tbl = (
@@ -301,7 +301,7 @@ def drop_table(self, identifier: Union[str, Identifier]) -> None:
301301 )
302302 session .delete (tbl )
303303 except NoResultFound as e :
304- raise NoSuchTableError (f"Table does not exist: { database_name } . { table_name } " ) from e
304+ raise NoSuchTableError (f"Table does not exist: { identifier_tuple } " ) from e
305305 session .commit ()
306306
307307 def rename_table (self , from_identifier : Union [str , Identifier ], to_identifier : Union [str , Identifier ]) -> Table :
@@ -501,6 +501,8 @@ def drop_namespace(self, namespace: Union[str, Identifier]) -> None:
501501 )
502502 )
503503 session .commit ()
504+ else :
505+ raise NoSuchNamespaceError (f"Namespace does not exist: { self .identifier_to_tuple (namespace )} " )
504506
505507 def list_tables (self , namespace : Union [str , Identifier ]) -> List [Identifier ]:
506508 """List tables under the given namespace in the catalog.
@@ -537,6 +539,10 @@ def list_namespaces(self, namespace: Union[str, Identifier] = ()) -> List[Identi
537539 Raises:
538540 NoSuchNamespaceError: If a namespace with the given name does not exist.
539541 """
542+ # Hierarchical namespace is not supported. Return an empty list
543+ if namespace :
544+ return []
545+
540546 if namespace and not self ._namespace_exists (namespace ):
541547 raise NoSuchNamespaceError (f"Namespace does not exist: { namespace } " )
542548
@@ -573,7 +579,9 @@ def load_namespace_properties(self, namespace: Union[str, Identifier]) -> Proper
573579 IcebergNamespaceProperties .catalog_name == self .name , IcebergNamespaceProperties .namespace == database_name
574580 )
575581 with Session (self .engine ) as session :
576- result = session .scalars (stmt )
582+ result = list (session .scalars (stmt ))
583+ if len (result ) == 0 :
584+ raise NoSuchNamespaceError (f"Namespace does not exist: { namespace } " )
577585 return {props .property_key : props .property_value for props in result }
578586
579587 def update_namespace_properties (
@@ -592,7 +600,7 @@ def update_namespace_properties(
592600 """
593601 database_name = self .identifier_to_database (namespace )
594602 if not self ._namespace_exists (database_name ):
595- raise NoSuchNamespaceError (f"Database { database_name } does not exists " )
603+ raise NoSuchNamespaceError (f"Namespace does not exist: { self . identifier_to_tuple ( namespace ) } " )
596604
597605 current_properties = self .load_namespace_properties (namespace = namespace )
598606 properties_update_summary = self ._get_updated_props_and_update_summary (
0 commit comments