Skip to content

Commit 20cea63

Browse files
committed
PR comments
1 parent f34ee55 commit 20cea63

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

pyiceberg/catalog/rest/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ def __init__(self, name: str, **properties: str):
232232
self._fetch_config()
233233
self._session = self._create_session()
234234
separator_from_properties = self.properties.get(NAMESPACE_SEPARATOR_PROPERTY, DEFAULT_NAMESPACE_SEPARATOR)
235+
if not separator_from_properties:
236+
raise ValueError("Namespace separator cannot be an empty string")
235237
self._namespace_separator = unquote(separator_from_properties)
236238

237239
def _create_session(self) -> Session:
@@ -396,8 +398,6 @@ def _identifier_to_validated_tuple(self, identifier: str | Identifier) -> Identi
396398
def _split_identifier_for_path(
397399
self, identifier: str | Identifier | TableIdentifier, kind: IdentifierKind = IdentifierKind.TABLE
398400
) -> Properties:
399-
from urllib.parse import quote
400-
401401
if isinstance(identifier, TableIdentifier):
402402
return {
403403
"namespace": self._encode_namespace_path(tuple(identifier.namespace.root)),
@@ -783,7 +783,7 @@ def list_namespaces(self, namespace: str | Identifier = ()) -> list[Identifier]:
783783
namespace_tuple = self.identifier_to_tuple(namespace)
784784
response = self._session.get(
785785
self.url(
786-
f"{Endpoints.list_namespaces}?parent={self._namespace_separator.join(namespace_tuple)}"
786+
f"{Endpoints.list_namespaces}?parent={self._encode_namespace_path(namespace_tuple)}"
787787
if namespace_tuple
788788
else Endpoints.list_namespaces
789789
),

tests/catalog/test_rest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1899,8 +1899,6 @@ def test_rest_catalog_with_google_credentials_path(
18991899
actual_headers = history[0].headers
19001900
assert actual_headers["Authorization"] == expected_auth_header
19011901

1902-
assert actual_headers["Authorization"] == expected_auth_header
1903-
19041902

19051903
def test_custom_namespace_separator(rest_mock: Mocker) -> None:
19061904
custom_separator = "-"
@@ -1917,7 +1915,7 @@ def test_custom_namespace_separator(rest_mock: Mocker) -> None:
19171915
rest_mock.get(
19181916
f"{TEST_URI}v1/namespaces/{expected_url_path_segment}",
19191917
json={"namespace": [namespace_part1, namespace_part2], "properties": {"prop": "yes"}},
1920-
status_code=204,
1918+
status_code=200,
19211919
request_headers=TEST_HEADERS,
19221920
)
19231921

0 commit comments

Comments
 (0)