@@ -414,9 +414,13 @@ def _create_hive_table(self, open_client: Client, hive_table: HiveTable) -> None
414414 raise TableAlreadyExistsError (f"Table { hive_table .dbName } .{ hive_table .tableName } already exists" ) from e
415415
416416 def _get_hive_table (self , open_client : Client , * , dbname : str , tbl_name : str ) -> HiveTable :
417- if all ((self ._client ._hive_version .major >= 4 , self ._client ._hive_version .minor > 0 )):
418- return open_client .get_table_req (GetTableRequest (dbName = dbname , tblName = tbl_name )).table
419- return open_client .get_table (dbname = dbname , tbl_name = tbl_name )
417+ try :
418+ if all ((self ._client ._hive_version .major >= 4 , self ._client ._hive_version .minor > 0 )):
419+ return open_client .get_table_req (GetTableRequest (dbName = dbname , tblName = tbl_name )).table
420+ return open_client .get_table (dbname = dbname , tbl_name = tbl_name )
421+ except NoSuchObjectException as e :
422+ raise NoSuchTableError (f"Table does not exists: { tbl_name } " ) from e
423+
420424
421425 def _get_table_objects_by_name (self , open_client : Client , * , dbname : str , tbl_names : list [str ]) -> list [HiveTable ]:
422426 if all ((self ._client ._hive_version .major >= 4 , self ._client ._hive_version .minor > 0 )):
@@ -465,7 +469,7 @@ def create_table(
465469
466470 with self ._client as open_client :
467471 self ._create_hive_table (open_client , tbl )
468- hive_table : HiveTable = self ._get_hive_table (open_client , dbname = database_name , tbl_name = table_name )
472+ hive_table = self ._get_hive_table (open_client , dbname = database_name , tbl_name = table_name )
469473
470474 return self ._convert_hive_into_iceberg (hive_table )
471475
@@ -495,7 +499,7 @@ def register_table(self, identifier: Union[str, Identifier], metadata_location:
495499 tbl = self ._convert_iceberg_into_hive (staged_table )
496500 with self ._client as open_client :
497501 self ._create_hive_table (open_client , tbl )
498- hive_table : HiveTable = self ._get_hive_table (open_client , dbname = database_name , tbl_name = table_name )
502+ hive_table = self ._get_hive_table (open_client , dbname = database_name , tbl_name = table_name )
499503
500504 return self ._convert_hive_into_iceberg (hive_table )
501505
@@ -681,12 +685,17 @@ def rename_table(self, from_identifier: Union[str, Identifier], to_identifier: U
681685 ValueError: When from table identifier is invalid.
682686 NoSuchTableError: When a table with the name does not exist.
683687 NoSuchNamespaceError: When the destination namespace doesn't exist.
688+ TableAlreadyExistsError: When the destination table already exists.
684689 """
685690 from_database_name , from_table_name = self .identifier_to_database_and_table (from_identifier , NoSuchTableError )
686691 to_database_name , to_table_name = self .identifier_to_database_and_table (to_identifier )
692+
693+ if self .table_exists (to_identifier ):
694+ raise TableAlreadyExistsError (f"Table already exists: { to_table_name } " )
695+
687696 try :
688697 with self ._client as open_client :
689- tbl : HiveTable = self ._get_hive_table (open_client , dbname = from_database_name , tbl_name = from_table_name )
698+ tbl = self ._get_hive_table (open_client , dbname = from_database_name , tbl_name = from_table_name )
690699 tbl .dbName = to_database_name
691700 tbl .tableName = to_table_name
692701 open_client .alter_table_with_environment_context (
@@ -830,7 +839,7 @@ def update_namespace_properties(
830839 if removals :
831840 for key in removals :
832841 if key in parameters :
833- parameters [ key ] = None
842+ parameters . pop ( key )
834843 removed .add (key )
835844 if updates :
836845 for key , value in updates .items ():
0 commit comments