@@ -157,6 +157,7 @@ class Endpoints:
157157 load_credentials : str = "namespaces/{namespace}/tables/{table}/credentials"
158158 update_table : str = "namespaces/{namespace}/tables/{table}"
159159 drop_table : str = "namespaces/{namespace}/tables/{table}"
160+ unregister_table : str = "namespaces/{namespace}/tables/{table}/unregister"
160161 table_exists : str = "namespaces/{namespace}/tables/{table}"
161162 get_token : str = "oauth/tokens"
162163 rename_table : str = "tables/rename"
@@ -192,6 +193,7 @@ class Capability:
192193 V1_DELETE_TABLE = Endpoint (http_method = HttpMethod .DELETE , path = f"{ API_PREFIX } /{ Endpoints .drop_table } " )
193194 V1_RENAME_TABLE = Endpoint (http_method = HttpMethod .POST , path = f"{ API_PREFIX } /{ Endpoints .rename_table } " )
194195 V1_REGISTER_TABLE = Endpoint (http_method = HttpMethod .POST , path = f"{ API_PREFIX } /{ Endpoints .register_table } " )
196+ V1_UNREGISTER_TABLE = Endpoint (http_method = HttpMethod .POST , path = f"{ API_PREFIX } /{ Endpoints .unregister_table } " )
195197 V1_LOAD_CREDENTIALS = Endpoint (http_method = HttpMethod .GET , path = f"{ API_PREFIX } /{ Endpoints .load_credentials } " )
196198
197199 V1_LIST_VIEWS = Endpoint (http_method = HttpMethod .GET , path = f"{ API_PREFIX } /{ Endpoints .list_views } " )
@@ -378,6 +380,16 @@ class RegisterTableRequest(IcebergBaseModel):
378380 overwrite : bool
379381
380382
383+ class UnregisterTableResult (IcebergBaseModel ):
384+ """Result of unregistering a table.
385+
386+ Contains the last metadata location and table metadata at the time of unregistration.
387+ """
388+
389+ metadata_location : str = Field (..., alias = "metadata-location" )
390+ metadata : TableMetadata
391+
392+
381393class RegisterViewRequest (IcebergBaseModel ):
382394 name : str
383395 metadata_location : str = Field (..., alias = "metadata-location" )
@@ -1249,6 +1261,32 @@ def register_table(self, identifier: str | Identifier, metadata_location: str, o
12491261 table_response = TableResponse .model_validate_json (response .text )
12501262 return self ._response_to_table (self .identifier_to_tuple (identifier ), table_response )
12511263
1264+ @retry (** _RETRY_ARGS )
1265+ def unregister_table (self , identifier : str | Identifier ) -> tuple [str , TableMetadata ]:
1266+ """Unregister a table from the catalog without removing data or metadata files.
1267+
1268+ Args:
1269+ identifier (Union[str, Identifier]): Table identifier for the table
1270+
1271+ Returns:
1272+ tuple[str, TableMetadata]: The last metadata location and corresponding table metadata
1273+
1274+ Raises:
1275+ NoSuchTableError: If the table does not exist
1276+ """
1277+ self ._check_endpoint (Capability .V1_UNREGISTER_TABLE )
1278+ namespace_and_table = self ._split_identifier_for_path (identifier )
1279+ response = self ._session .post (
1280+ self .url (Endpoints .unregister_table , prefixed = True , ** namespace_and_table ),
1281+ )
1282+ try :
1283+ response .raise_for_status ()
1284+ except HTTPError as exc :
1285+ _handle_non_200_response (exc , {404 : NoSuchTableError })
1286+
1287+ result = UnregisterTableResult .model_validate_json (response .content )
1288+ return (result .metadata_location , result .metadata )
1289+
12521290 @retry (** _RETRY_ARGS )
12531291 @override
12541292 def list_tables (self , namespace : str | Identifier ) -> list [Identifier ]:
0 commit comments