Skip to content

Commit 6a07478

Browse files
committed
fixup! Add drop_view to the rest catalog
1 parent 2756625 commit 6a07478

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

pyiceberg/catalog/rest.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
from enum import Enum
1718
from json import JSONDecodeError
1819
from typing import (
1920
TYPE_CHECKING,
@@ -102,6 +103,11 @@ class Endpoints:
102103
drop_view: str = "namespaces/{namespace}/views/{view}"
103104

104105

106+
class IdentifierKind(Enum):
107+
TABLE = "table"
108+
VIEW = "view"
109+
110+
105111
AUTHORIZATION_HEADER = "Authorization"
106112
BEARER_PREFIX = "Bearer"
107113
CATALOG_SCOPE = "catalog"
@@ -395,15 +401,17 @@ def _identifier_to_validated_tuple(self, identifier: Union[str, Identifier]) ->
395401
raise NoSuchIdentifierError(f"Missing namespace or invalid identifier: {'.'.join(identifier_tuple)}")
396402
return identifier_tuple
397403

398-
def _split_identifier_for_path(self, identifier: Union[str, Identifier, TableIdentifier], kind: str = "table") -> Properties:
404+
def _split_identifier_for_path(
405+
self, identifier: Union[str, Identifier, TableIdentifier], kind: IdentifierKind = IdentifierKind.TABLE
406+
) -> Properties:
399407
if isinstance(identifier, TableIdentifier):
400408
if identifier.namespace.root[0] == self.name:
401-
return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root[1:]), "table": identifier.name}
409+
return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root[1:]), kind.value: identifier.name}
402410
else:
403-
return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root), "table": identifier.name}
411+
return {"namespace": NAMESPACE_SEPARATOR.join(identifier.namespace.root), kind.value: identifier.name}
404412
identifier_tuple = self._identifier_to_validated_tuple(identifier)
405413

406-
return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), kind: identifier_tuple[-1]}
414+
return {"namespace": NAMESPACE_SEPARATOR.join(identifier_tuple[:-1]), kind.value: identifier_tuple[-1]}
407415

408416
def _split_identifier_for_json(self, identifier: Union[str, Identifier]) -> Dict[str, Union[Identifier, str]]:
409417
identifier_tuple = self._identifier_to_validated_tuple(identifier)
@@ -876,7 +884,9 @@ def table_exists(self, identifier: Union[str, Identifier]) -> bool:
876884
def drop_view(self, identifier: Union[str]) -> None:
877885
identifier_tuple = self.identifier_to_tuple_without_catalog(identifier)
878886
response = self._session.delete(
879-
self.url(Endpoints.drop_view, prefixed=True, **self._split_identifier_for_path(identifier_tuple, kind="view")),
887+
self.url(
888+
Endpoints.drop_view, prefixed=True, **self._split_identifier_for_path(identifier_tuple, IdentifierKind.VIEW)
889+
),
880890
)
881891
try:
882892
response.raise_for_status()

0 commit comments

Comments
 (0)