Skip to content

Commit 04a02ce

Browse files
committed
X-Client-Version header parity with Iceberg java
1 parent b0a7878 commit 04a02ce

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

pyiceberg/catalog/rest/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ def _config_headers(self, session: Session) -> None:
491491
session.headers.update(header_properties)
492492
session.headers["Content-type"] = "application/json"
493493
session.headers["User-Agent"] = f"PyIceberg/{__version__}"
494+
session.headers["X-Client-Version"] = f"Apache PyIceberg {__version__}"
494495
session.headers.setdefault("X-Iceberg-Access-Delegation", ACCESS_DELEGATION_DEFAULT)
495496

496497
def _create_table(

tests/catalog/test_rest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,6 +1922,12 @@ def test_auth_header(rest_mock: Mocker) -> None:
19221922
assert mock_request.last_request.text == "grant_type=client_credentials&client_id=client&client_secret=secret&scope=catalog"
19231923

19241924

1925+
def test_client_version_header(rest_mock: Mocker) -> None:
1926+
catalog = RestCatalog("rest", uri=TEST_URI, warehouse="s3://some-bucket")
1927+
assert catalog._session.headers.get("X-Client-Version") == f"Apache PyIceberg {pyiceberg.__version__}"
1928+
assert rest_mock.last_request.headers["X-Client-Version"] == f"Apache PyIceberg {pyiceberg.__version__}"
1929+
1930+
19251931
class TestRestCatalogClose:
19261932
"""Tests RestCatalog close functionality"""
19271933

0 commit comments

Comments
 (0)