diff --git a/pyiceberg/catalog/rest/__init__.py b/pyiceberg/catalog/rest/__init__.py index a28ff562bd..3daaeb3f2b 100644 --- a/pyiceberg/catalog/rest/__init__.py +++ b/pyiceberg/catalog/rest/__init__.py @@ -491,6 +491,7 @@ def _config_headers(self, session: Session) -> None: session.headers.update(header_properties) session.headers["Content-type"] = "application/json" session.headers["User-Agent"] = f"PyIceberg/{__version__}" + session.headers["X-Client-Version"] = f"Apache PyIceberg {__version__}" session.headers.setdefault("X-Iceberg-Access-Delegation", ACCESS_DELEGATION_DEFAULT) def _create_table( diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py index 464314f3be..a5c7267b43 100644 --- a/tests/catalog/test_rest.py +++ b/tests/catalog/test_rest.py @@ -1922,6 +1922,12 @@ def test_auth_header(rest_mock: Mocker) -> None: assert mock_request.last_request.text == "grant_type=client_credentials&client_id=client&client_secret=secret&scope=catalog" +def test_client_version_header(rest_mock: Mocker) -> None: + catalog = RestCatalog("rest", uri=TEST_URI, warehouse="s3://some-bucket") + assert catalog._session.headers.get("X-Client-Version") == f"Apache PyIceberg {pyiceberg.__version__}" + assert rest_mock.last_request.headers["X-Client-Version"] == f"Apache PyIceberg {pyiceberg.__version__}" + + class TestRestCatalogClose: """Tests RestCatalog close functionality"""