Skip to content

Commit f1668f7

Browse files
committed
let requests handle the params
1 parent eee7c08 commit f1668f7

2 files changed

Lines changed: 4 additions & 40 deletions

File tree

pyiceberg/catalog/rest/__init__.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class Endpoints:
9999
register_table = "namespaces/{namespace}/register"
100100
load_table: str = "namespaces/{namespace}/tables/{table}"
101101
update_table: str = "namespaces/{namespace}/tables/{table}"
102-
drop_table: str = "namespaces/{namespace}/tables/{table}?purgeRequested={purge}"
102+
drop_table: str = "namespaces/{namespace}/tables/{table}"
103103
table_exists: str = "namespaces/{namespace}/tables/{table}"
104104
get_token: str = "oauth/tokens"
105105
rename_table: str = "tables/rename"
@@ -108,30 +108,6 @@ class Endpoints:
108108
view_exists: str = "namespaces/{namespace}/views/{view}"
109109

110110

111-
ENDPOINT_PARAMS_MAP: dict[str, tuple[str]] = {
112-
Endpoints.drop_table: ("purgeRequested",),
113-
}
114-
115-
116-
def _get_endpoint_params(endpoint: str, **kwargs: Any) -> dict[str, Any] | None:
117-
"""Get the query parameters for the endpoint."""
118-
if not kwargs or endpoint not in ENDPOINT_PARAMS_MAP:
119-
return None
120-
121-
snake_case_query_params = {
122-
param: CAMEL_TO_SNAKE_CASE_PATTERN.sub("_", param).lower() for param in ENDPOINT_PARAMS_MAP[endpoint]
123-
}
124-
125-
_params = {}
126-
for camel, snake in snake_case_query_params.items():
127-
if snake in kwargs:
128-
if kwargs[snake] is None:
129-
continue
130-
_params[camel] = kwargs[snake]
131-
132-
return _params
133-
134-
135111
class IdentifierKind(Enum):
136112
TABLE = "table"
137113
VIEW = "view"
@@ -644,9 +620,9 @@ def load_table(self, identifier: Union[str, Identifier]) -> Table:
644620

645621
@retry(**_RETRY_ARGS)
646622
def drop_table(self, identifier: Union[str, Identifier], purge_requested: bool = False) -> None:
647-
params = _get_endpoint_params(Endpoints.drop_table, purge_requested=purge_requested)
648623
response = self._session.delete(
649-
self.url(Endpoints.drop_table, prefixed=True, **self._split_identifier_for_path(identifier)), params=params
624+
self.url(Endpoints.drop_table, prefixed=True, **self._split_identifier_for_path(identifier)),
625+
params={"purgeRequested": purge_requested},
650626
)
651627
try:
652628
response.raise_for_status()

tests/catalog/test_rest.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import pyiceberg
2626
from pyiceberg.catalog import PropertiesUpdateSummary, load_catalog
27-
from pyiceberg.catalog.rest import OAUTH2_SERVER_URI, SNAPSHOT_LOADING_MODE, Endpoints, RestCatalog, _get_endpoint_params
27+
from pyiceberg.catalog.rest import OAUTH2_SERVER_URI, SNAPSHOT_LOADING_MODE, RestCatalog
2828
from pyiceberg.exceptions import (
2929
AuthorizationExpiredError,
3030
NamespaceAlreadyExistsError,
@@ -1621,15 +1621,3 @@ def test_drop_view_204(rest_mock: Mocker) -> None:
16211621
request_headers=TEST_HEADERS,
16221622
)
16231623
RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN).drop_view(("some_namespace", "some_view"))
1624-
1625-
1626-
def test_get_endpoint_params() -> None:
1627-
params = _get_endpoint_params(Endpoints.drop_table, purge_requested=True)
1628-
assert params == {
1629-
"purgeRequested": True,
1630-
}
1631-
1632-
1633-
def test_get_endpoint_with_no_params() -> None:
1634-
params = _get_endpoint_params(Endpoints.namespace_exists, purge_requested=True)
1635-
assert params is None

0 commit comments

Comments
 (0)