|
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 |
@@ -97,6 +98,7 @@ class Endpoints: |
97 | 98 | table_exists: str = "namespaces/{namespace}/tables/{table}" |
98 | 99 | get_token: str = "oauth/tokens" |
99 | 100 | rename_table: str = "tables/rename" |
| 101 | + drop_view: str = "namespaces/{namespace}/views/{view}" |
100 | 102 |
|
101 | 103 |
|
102 | 104 | AUTHORIZATION_HEADER = "Authorization" |
@@ -383,14 +385,15 @@ def _identifier_to_validated_tuple(self, identifier: Union[str, Identifier]) -> |
383 | 385 | raise NoSuchIdentifierError(f"Missing namespace or invalid identifier: {'.'.join(identifier_tuple)}") |
384 | 386 | return identifier_tuple |
385 | 387 |
|
386 | | - def _split_identifier_for_path(self, identifier: Union[str, Identifier, TableIdentifier]) -> Properties: |
| 388 | + def _split_identifier_for_path(self, identifier: Union[str, Identifier, TableIdentifier], kind: str = "table") -> Properties: |
387 | 389 | if isinstance(identifier, TableIdentifier): |
388 | 390 | if identifier.namespace.root[0] == self.name: |
389 | 391 | return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root[1:]), "table": identifier.name} |
390 | 392 | else: |
391 | 393 | return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root), "table": identifier.name} |
392 | 394 | identifier_tuple = self._identifier_to_validated_tuple(identifier) |
393 | | - return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), "table": identifier_tuple[-1]} |
| 395 | + |
| 396 | + return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), kind: identifier_tuple[-1]} |
394 | 397 |
|
395 | 398 | def _split_identifier_for_json(self, identifier: Union[str, Identifier]) -> Dict[str, Union[Identifier, str]]: |
396 | 399 | identifier_tuple = self._identifier_to_validated_tuple(identifier) |
@@ -836,3 +839,14 @@ def table_exists(self, identifier: Union[str, Identifier]) -> bool: |
836 | 839 | self.url(Endpoints.load_table, prefixed=True, **self._split_identifier_for_path(identifier_tuple)) |
837 | 840 | ) |
838 | 841 | return response.status_code in (200, 204) |
| 842 | + |
| 843 | + @retry(**_RETRY_ARGS) |
| 844 | + def drop_view(self, identifier: Union[str]) -> None: |
| 845 | + identifier_tuple = self.identifier_to_tuple_without_catalog(identifier) |
| 846 | + response = self._session.delete( |
| 847 | + self.url(Endpoints.drop_view, prefixed=True, **self._split_identifier_for_path(identifier_tuple, kind="view")), |
| 848 | + ) |
| 849 | + try: |
| 850 | + response.raise_for_status() |
| 851 | + except HTTPError as exc: |
| 852 | + self._handle_non_200_response(exc, {404: NoSuchViewError}) |
0 commit comments