diff --git a/pyiceberg/catalog/rest.py b/pyiceberg/catalog/rest.py index 20a04d9c5b..7c5d774c27 100644 --- a/pyiceberg/catalog/rest.py +++ b/pyiceberg/catalog/rest.py @@ -525,6 +525,7 @@ def _response_to_table(self, identifier_tuple: Tuple[str, ...], table_response: {**table_response.metadata.properties, **table_response.config}, table_response.metadata_location ), catalog=self, + config=table_response.config, ) def _response_to_staged_table(self, identifier_tuple: Tuple[str, ...], table_response: TableResponse) -> StagedTable: @@ -777,9 +778,15 @@ def commit_table( identifier = self._identifier_to_tuple_without_catalog(table.identifier) table_identifier = TableIdentifier(namespace=identifier[:-1], name=identifier[-1]) table_request = CommitTableRequest(identifier=table_identifier, requirements=requirements, updates=updates) + + headers = self._session.headers + if table_token := table.config.get(TOKEN): + headers[AUTHORIZATION_HEADER] = f"{BEARER_PREFIX} {table_token}" + response = self._session.post( self.url(Endpoints.update_table, prefixed=True, **self._split_identifier_for_path(table_request.identifier)), data=table_request.model_dump_json().encode(UTF8), + headers=headers, ) try: response.raise_for_status() diff --git a/pyiceberg/table/__init__.py b/pyiceberg/table/__init__.py index 264afd8971..18942948c0 100644 --- a/pyiceberg/table/__init__.py +++ b/pyiceberg/table/__init__.py @@ -784,15 +784,23 @@ class Table: metadata_location: str = Field() io: FileIO catalog: Catalog + config: Dict[str, str] def __init__( - self, identifier: Identifier, metadata: TableMetadata, metadata_location: str, io: FileIO, catalog: Catalog + self, + identifier: Identifier, + metadata: TableMetadata, + metadata_location: str, + io: FileIO, + catalog: Catalog, + config: Dict[str, str] = EMPTY_DICT, ) -> None: self._identifier = identifier self.metadata = metadata self.metadata_location = metadata_location self.io = io self.catalog = catalog + self.config = config def transaction(self) -> Transaction: """Create a new transaction object to first stage the changes, and then commit them to the catalog.