|
48 | 48 | ForbiddenError, |
49 | 49 | NamespaceAlreadyExistsError, |
50 | 50 | NamespaceNotEmptyError, |
| 51 | + NoSuchIdentifierError, |
51 | 52 | NoSuchNamespaceError, |
52 | 53 | NoSuchTableError, |
| 54 | + NoSuchViewError, |
53 | 55 | OAuthError, |
54 | 56 | RESTError, |
55 | 57 | ServerError, |
56 | 58 | ServiceUnavailableError, |
57 | 59 | TableAlreadyExistsError, |
58 | 60 | UnauthorizedError, |
59 | | - NoSuchIdentifierError, |
60 | 61 | ) |
61 | 62 | from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec, assign_fresh_partition_spec_ids |
62 | 63 | from pyiceberg.schema import Schema, assign_fresh_schema_ids |
@@ -98,6 +99,7 @@ class Endpoints: |
98 | 99 | get_token: str = "oauth/tokens" |
99 | 100 | rename_table: str = "tables/rename" |
100 | 101 | list_views: str = "namespaces/{namespace}/views" |
| 102 | + drop_view: str = "namespaces/{namespace}/views/{view}" |
101 | 103 |
|
102 | 104 |
|
103 | 105 | AUTHORIZATION_HEADER = "Authorization" |
@@ -393,14 +395,15 @@ def _identifier_to_validated_tuple(self, identifier: Union[str, Identifier]) -> |
393 | 395 | raise NoSuchIdentifierError(f"Missing namespace or invalid identifier: {'.'.join(identifier_tuple)}") |
394 | 396 | return identifier_tuple |
395 | 397 |
|
396 | | - def _split_identifier_for_path(self, identifier: Union[str, Identifier, TableIdentifier]) -> Properties: |
| 398 | + def _split_identifier_for_path(self, identifier: Union[str, Identifier, TableIdentifier], kind: str = "table") -> Properties: |
397 | 399 | if isinstance(identifier, TableIdentifier): |
398 | 400 | if identifier.namespace.root[0] == self.name: |
399 | 401 | return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root[1:]), "table": identifier.name} |
400 | 402 | else: |
401 | 403 | return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root), "table": identifier.name} |
402 | 404 | identifier_tuple = self._identifier_to_validated_tuple(identifier) |
403 | | - return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), "table": identifier_tuple[-1]} |
| 405 | + |
| 406 | + return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), kind: identifier_tuple[-1]} |
404 | 407 |
|
405 | 408 | def _split_identifier_for_json(self, identifier: Union[str, Identifier]) -> Dict[str, Union[Identifier, str]]: |
406 | 409 | identifier_tuple = self._identifier_to_validated_tuple(identifier) |
@@ -868,3 +871,14 @@ def table_exists(self, identifier: Union[str, Identifier]) -> bool: |
868 | 871 | self._handle_non_200_response(exc, {}) |
869 | 872 |
|
870 | 873 | return False |
| 874 | + |
| 875 | + @retry(**_RETRY_ARGS) |
| 876 | + def drop_view(self, identifier: Union[str]) -> None: |
| 877 | + identifier_tuple = self.identifier_to_tuple_without_catalog(identifier) |
| 878 | + response = self._session.delete( |
| 879 | + self.url(Endpoints.drop_view, prefixed=True, **self._split_identifier_for_path(identifier_tuple, kind="view")), |
| 880 | + ) |
| 881 | + try: |
| 882 | + response.raise_for_status() |
| 883 | + except HTTPError as exc: |
| 884 | + self._handle_non_200_response(exc, {404: NoSuchViewError}) |
0 commit comments