geruh commented on code in PR #2826:
URL: https://github.com/apache/iceberg-python/pull/2826#discussion_r2615963814


##########
pyiceberg/catalog/rest/__init__.py:
##########
@@ -381,11 +396,19 @@ def _identifier_to_validated_tuple(self, identifier: str 
| Identifier) -> Identi
     def _split_identifier_for_path(
         self, identifier: str | Identifier | TableIdentifier, kind: 
IdentifierKind = IdentifierKind.TABLE
     ) -> Properties:
+        from urllib.parse import quote

Review Comment:
   nit: duplicate import 



##########
pyiceberg/catalog/rest/__init__.py:
##########
@@ -228,6 +231,8 @@ def __init__(self, name: str, **properties: str):
         self.uri = properties[URI]
         self._fetch_config()
         self._session = self._create_session()
+        separator_from_properties = 
self.properties.get(NAMESPACE_SEPARATOR_PROPERTY, DEFAULT_NAMESPACE_SEPARATOR)
+        self._namespace_separator = unquote(separator_from_properties)

Review Comment:
   Can we add some validation logic on the ns separator property to ensure it's 
not empty



##########
tests/catalog/test_rest.py:
##########
@@ -1899,6 +1899,33 @@ def test_rest_catalog_with_google_credentials_path(
     actual_headers = history[0].headers
     assert actual_headers["Authorization"] == expected_auth_header
 
+    assert actual_headers["Authorization"] == expected_auth_header

Review Comment:
   nit: duplicate line here



##########
pyiceberg/catalog/rest/__init__.py:
##########
@@ -760,7 +783,7 @@ def list_namespaces(self, namespace: str | Identifier = ()) 
-> list[Identifier]:
         namespace_tuple = self.identifier_to_tuple(namespace)
         response = self._session.get(
             self.url(
-                
f"{Endpoints.list_namespaces}?parent={NAMESPACE_SEPARATOR.join(namespace_tuple)}"
+                
f"{Endpoints.list_namespaces}?parent={self._namespace_separator.join(namespace_tuple)}"

Review Comment:
   This should use the `self._encode_namespace_path`



##########
tests/catalog/test_rest.py:
##########
@@ -1899,6 +1899,33 @@ def test_rest_catalog_with_google_credentials_path(
     actual_headers = history[0].headers
     assert actual_headers["Authorization"] == expected_auth_header
 
+    assert actual_headers["Authorization"] == expected_auth_header
+
+
+def test_custom_namespace_separator(rest_mock: Mocker) -> None:
+    custom_separator = "-"
+    namespace_part1 = "some"
+    namespace_part2 = "namespace"
+    # The expected URL path segment should use the literal custom_separator
+    expected_url_path_segment = 
f"{namespace_part1}{custom_separator}{namespace_part2}"
+
+    rest_mock.get(
+        f"{TEST_URI}v1/config",
+        json={"defaults": {}, "overrides": {}},
+        status_code=200,
+    )
+    rest_mock.get(
+        f"{TEST_URI}v1/namespaces/{expected_url_path_segment}",
+        json={"namespace": [namespace_part1, namespace_part2], "properties": 
{"prop": "yes"}},
+        status_code=204,

Review Comment:
   200 for getNamespace



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to