Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyiceberg/catalog/rest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 9 additions & 1 deletion pyiceberg/view/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
Soumo-git-hub marked this conversation as resolved.

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."""
Expand Down Expand Up @@ -92,4 +96,8 @@ def sql_for(self, dialect: str) -> SQLViewRepresentation | None:

def __eq__(self, other: Any) -> bool:
"""Return the equality of two instances of the View class."""
return self.name() == other.name() and self.metadata == other.metadata if isinstance(other, View) else False
return (
self.name() == other.name() and self.metadata == other.metadata and self.metadata_location == other.metadata_location
if isinstance(other, View)
else False
)
8 changes: 7 additions & 1 deletion tests/catalog/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,7 @@ def test_create_view_200(rest_mock: Mocker, table_schema_simple: Schema, example
expected = View(
identifier=("fokko", "fokko2"),
metadata=ViewMetadata(**example_view_metadata_rest_json["metadata"]),
metadata_location=example_view_metadata_rest_json["metadata-location"],
)
assert actual == expected
assert actual.config == example_view_metadata_rest_json["config"]
Expand Down Expand Up @@ -1846,7 +1847,11 @@ def test_load_view_200(rest_mock: Mocker, example_view_metadata_rest_json: dict[
)
catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN)
actual = catalog.load_view(("fokko", "view"))
expected = View(identifier=("fokko", "view"), metadata=ViewMetadata(**example_view_metadata_rest_json["metadata"]))
expected = View(
identifier=("fokko", "view"),
metadata=ViewMetadata(**example_view_metadata_rest_json["metadata"]),
metadata_location=example_view_metadata_rest_json["metadata-location"],
)
assert actual == expected
assert actual.config == example_view_metadata_rest_json["config"]

Expand Down Expand Up @@ -2806,6 +2811,7 @@ def test_register_view_200(rest_mock: Mocker, example_view_metadata_rest_json: d
expected = View(
identifier=("default", "registered_view"),
metadata=ViewMetadata(**example_view_metadata_rest_json["metadata"]),
metadata_location=example_view_metadata_rest_json["metadata-location"],
)
assert actual == expected
assert actual.config == example_view_metadata_rest_json["config"]
Expand Down
1 change: 1 addition & 0 deletions tests/integration/test_rest_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def test_load_view(catalog: RestCatalog, table_schema_nested: Schema, database_n
)
view = catalog.create_view(identifier, table_schema_nested, view_version=view_version)
loaded_view = catalog.load_view(identifier)
assert view.metadata_location is not None
assert view == loaded_view


Expand Down
Loading