gabeiglio commented on code in PR #3288:
URL: https://github.com/apache/iceberg-python/pull/3288#discussion_r3143711261
##########
pyiceberg/catalog/rest/__init__.py:
##########
@@ -1312,6 +1319,27 @@ def view_exists(self, identifier: str | Identifier) ->
bool:
return False
+ @retry(**_RETRY_ARGS)
+ def register_view(self, identifier: str | Identifier, metadata_location:
str) -> View:
+ self._check_endpoint(Capability.V1_REGISTER_VIEW)
+ namespace_and_view = self._split_identifier_for_path(identifier)
+ request = RegisterViewRequest(
+ name=self._identifier_to_validated_tuple(identifier)[-1],
+ metadata_location=metadata_location,
+ )
+ serialized_json = request.model_dump_json().encode(UTF8)
+ response = self._session.post(
+ self.url(Endpoints.register_view,
namespace=namespace_and_view["namespace"]),
+ data=serialized_json,
+ )
+ try:
+ response.raise_for_status()
+ except HTTPError as exc:
+ _handle_non_200_response(exc, {409: ViewAlreadyExistsError})
Review Comment:
Wonder if here we can catch a TableAlreadyExists if there is a table already
registered with the same identifier
##########
pyiceberg/catalog/rest/__init__.py:
##########
@@ -1312,6 +1319,27 @@ def view_exists(self, identifier: str | Identifier) ->
bool:
return False
+ @retry(**_RETRY_ARGS)
+ def register_view(self, identifier: str | Identifier, metadata_location:
str) -> View:
+ self._check_endpoint(Capability.V1_REGISTER_VIEW)
+ namespace_and_view = self._split_identifier_for_path(identifier)
+ request = RegisterViewRequest(
+ name=self._identifier_to_validated_tuple(identifier)[-1],
+ metadata_location=metadata_location,
+ )
+ serialized_json = request.model_dump_json().encode(UTF8)
+ response = self._session.post(
+ self.url(Endpoints.register_view,
namespace=namespace_and_view["namespace"]),
+ data=serialized_json,
+ )
+ try:
+ response.raise_for_status()
+ except HTTPError as exc:
+ _handle_non_200_response(exc, {409: ViewAlreadyExistsError})
Review Comment:
Wonder if here we can catch a TableAlreadyExists if there is a table already
registered with the same identifier?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]