diff --git a/pyiceberg/catalog/rest/__init__.py b/pyiceberg/catalog/rest/__init__.py index 88bbd29bef..57f1f89127 100644 --- a/pyiceberg/catalog/rest/__init__.py +++ b/pyiceberg/catalog/rest/__init__.py @@ -1187,6 +1187,7 @@ def _response_to_view(self, identifier_tuple: tuple[str, ...], view_response: Vi identifier=identifier_tuple, metadata=view_response.metadata, config=view_response.config, + metadata_location=view_response.metadata_location, ) def _refresh_token(self) -> None: diff --git a/pyiceberg/view/__init__.py b/pyiceberg/view/__init__.py index 4f298e5b60..e2f7bb97d4 100644 --- a/pyiceberg/view/__init__.py +++ b/pyiceberg/view/__init__.py @@ -30,16 +30,20 @@ class View: _identifier: Identifier metadata: ViewMetadata config: dict[str, str] + # None when no metadata location is available, such as for directly constructed views. + metadata_location: str | None def __init__( self, identifier: Identifier, metadata: ViewMetadata, config: dict[str, str] = EMPTY_DICT, + metadata_location: str | None = None, ) -> None: self._identifier = identifier self.metadata = metadata self.config = config + self.metadata_location = metadata_location def name(self) -> Identifier: """Return the identifier of this view.""" @@ -92,4 +96,5 @@ def sql_for(self, dialect: str) -> SQLViewRepresentation | None: def __eq__(self, other: Any) -> bool: """Return the equality of two instances of the View class.""" + # Metadata location is intentionally excluded from view equality. return self.name() == other.name() and self.metadata == other.metadata if isinstance(other, View) else False diff --git a/tests/catalog/test_rest.py b/tests/catalog/test_rest.py index b06281bcef..18028ed6ab 100644 --- a/tests/catalog/test_rest.py +++ b/tests/catalog/test_rest.py @@ -1765,6 +1765,7 @@ def test_create_view_200(rest_mock: Mocker, table_schema_simple: Schema, example ) assert actual == expected assert actual.config == example_view_metadata_rest_json["config"] + assert actual.metadata_location == example_view_metadata_rest_json["metadata-location"] def test_create_view_409( @@ -1812,6 +1813,7 @@ def test_load_view_200(rest_mock: Mocker, example_view_metadata_rest_json: dict[ expected = View(identifier=("fokko", "view"), metadata=ViewMetadata(**example_view_metadata_rest_json["metadata"])) assert actual == expected assert actual.config == example_view_metadata_rest_json["config"] + assert actual.metadata_location == example_view_metadata_rest_json["metadata-location"] def test_load_view_404(rest_mock: Mocker) -> None: @@ -2772,6 +2774,7 @@ def test_register_view_200(rest_mock: Mocker, example_view_metadata_rest_json: d ) assert actual == expected assert actual.config == example_view_metadata_rest_json["config"] + assert actual.metadata_location == example_view_metadata_rest_json["metadata-location"] def test_register_view_409_view(rest_mock: Mocker) -> None: