|
47 | 47 | CommitStateUnknownException, |
48 | 48 | ForbiddenError, |
49 | 49 | NamespaceAlreadyExistsError, |
| 50 | + NoSuchIdentifierError, |
50 | 51 | NoSuchNamespaceError, |
51 | 52 | NoSuchTableError, |
| 53 | + NoSuchViewError, |
52 | 54 | OAuthError, |
53 | 55 | RESTError, |
54 | 56 | ServerError, |
55 | 57 | ServiceUnavailableError, |
56 | 58 | TableAlreadyExistsError, |
57 | 59 | UnauthorizedError, |
58 | | - NoSuchIdentifierError, |
59 | 60 | ) |
60 | 61 | from pyiceberg.partitioning import UNPARTITIONED_PARTITION_SPEC, PartitionSpec, assign_fresh_partition_spec_ids |
61 | 62 | from pyiceberg.schema import Schema, assign_fresh_schema_ids |
@@ -94,6 +95,7 @@ class Endpoints: |
94 | 95 | table_exists: str = "namespaces/{namespace}/tables/{table}" |
95 | 96 | get_token: str = "oauth/tokens" |
96 | 97 | rename_table: str = "tables/rename" |
| 98 | + drop_view: str = "namespaces/{namespace}/views/{view}" |
97 | 99 |
|
98 | 100 |
|
99 | 101 | AUTHORIZATION_HEADER = "Authorization" |
@@ -352,11 +354,12 @@ def _identifier_to_validated_tuple(self, identifier: Union[str, Identifier]) -> |
352 | 354 | raise NoSuchIdentifierError(f"Missing namespace or invalid identifier: {'.'.join(identifier_tuple)}") |
353 | 355 | return identifier_tuple |
354 | 356 |
|
355 | | - def _split_identifier_for_path(self, identifier: Union[str, Identifier, TableIdentifier]) -> Properties: |
| 357 | + def _split_identifier_for_path(self, identifier: Union[str, Identifier, TableIdentifier], kind: str = "table") -> Properties: |
356 | 358 | if isinstance(identifier, TableIdentifier): |
357 | 359 | return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root[1:]), "table": identifier.name} |
358 | 360 | identifier_tuple = self._identifier_to_validated_tuple(identifier) |
359 | | - return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), "table": identifier_tuple[-1]} |
| 361 | + |
| 362 | + return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), kind: identifier_tuple[-1]} |
360 | 363 |
|
361 | 364 | def _split_identifier_for_json(self, identifier: Union[str, Identifier]) -> Dict[str, Union[Identifier, str]]: |
362 | 365 | identifier_tuple = self._identifier_to_validated_tuple(identifier) |
@@ -792,3 +795,14 @@ def table_exists(self, identifier: Union[str, Identifier]) -> bool: |
792 | 795 | self.url(Endpoints.load_table, prefixed=True, **self._split_identifier_for_path(identifier_tuple)) |
793 | 796 | ) |
794 | 797 | return response.status_code in (200, 204) |
| 798 | + |
| 799 | + @retry(**_RETRY_ARGS) |
| 800 | + def drop_view(self, identifier: Union[str]) -> None: |
| 801 | + identifier_tuple = self.identifier_to_tuple_without_catalog(identifier) |
| 802 | + response = self._session.delete( |
| 803 | + self.url(Endpoints.drop_view, prefixed=True, **self._split_identifier_for_path(identifier_tuple, kind="view")), |
| 804 | + ) |
| 805 | + try: |
| 806 | + response.raise_for_status() |
| 807 | + except HTTPError as exc: |
| 808 | + self._handle_non_200_response(exc, {404: NoSuchViewError}) |
0 commit comments