You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "shiv-io (via GitHub)" <gi...@apache.org> on 2024/10/20 19:48:47 UTC

[PR] Add `view_exists` method to REST Catalog [iceberg-python]

shiv-io opened a new pull request, #1242:
URL: https://github.com/apache/iceberg-python/pull/1242

   Part of the adding view support to the REST catalog: #818 


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2628592600

   Thanks for the contribution! @shiv-io 


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "shiv-io (via GitHub)" <gi...@apache.org>.
shiv-io commented on code in PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#discussion_r1833516291


##########
tests/catalog/test_rest.py:
##########
@@ -450,6 +450,28 @@ def test_list_views_404(rest_mock: Mocker) -> None:
     assert "Namespace does not exist" in str(e.value)
 
 
+def test_view_exists_204(rest_mock: Mocker) -> None:
+    namespace = "examples"
+    view = "some_view"
+    rest_mock.head(
+        f"{TEST_URI}v1/namespaces/{namespace}/views/{view}",
+        status_code=204,
+        request_headers=TEST_HEADERS,
+    )
+    catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN)
+    assert catalog.view_exists((namespace, view))
+
+def test_view_exists_404(rest_mock: Mocker) -> None:
+    namespace = "examples"
+    view = "some_view"
+    rest_mock.head(
+        f"{TEST_URI}v1/namespaces/{namespace}/views/{view}",

Review Comment:
   @sungwy thanks! Is that as simple as creating a test case with:
   ```python
   multilevel_namespace = "core.examples.some_namespace"
   view = "some_view"
   rest_mock.head(
       f"{TEST_URI}v1/namespaces/{multilevel_namespace}/views/{view}",
       status_code=404,
       request_headers=TEST_HEADERS,
   )
   ```



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2593215982

   @shiv-io Gentle ping :)


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "sungwy (via GitHub)" <gi...@apache.org>.
sungwy commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2524819444

   Hi @shiv-io !
   
   Sorry this fell off my radar. Could we actually add an integration test here as well, now that we have a new REST Catalog image we are testing against that supports the view endpoints? :)
   
   https://github.com/apache/iceberg-python/pull/1389


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "shiv-io (via GitHub)" <gi...@apache.org>.
shiv-io commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2606155161

   @sungwy thanks for the review :)


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "shiv-io (via GitHub)" <gi...@apache.org>.
shiv-io commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2425262513

   When I tested `catalog.view_exists('default.bar')` with a local REST catalog, I got the following exception. This also occurs with the existing `catalog.table_exists()` method. Is this expected?
   
   ```python
   from pyiceberg.catalog.rest import RestCatalog
   
   catalog = RestCatalog(
       name='local',
       **{
           'uri': 'http://0.0.0.0:8181'
       }
   )
   
   catalog.view_exists('default.bar')
   
   # Traceback (most recent call last):
   #   File "/Users/shivgupta/projects/iceberg-python/pyiceberg/catalog/rest.py", line 916, in view_exists
   #     response.raise_for_status()
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/requests/models.py", line 1024, in raise_for_status
   #     raise HTTPError(http_error_msg, response=self)
   # requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://0.0.0.0:8181/v1/namespaces/default/views/bar
   
   # The above exception was the direct cause of the following exception:
   
   # Traceback (most recent call last):
   #   File "<stdin>", line 1, in <module>
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 336, in wrapped_f
   #     return copy(f, *args, **kw)
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 475, in __call__
   # >>> catalog.view_exists('default.bar')
   # Traceback (most recent call last):
   #   File "/Users/shivgupta/projects/iceberg-python/pyiceberg/catalog/rest.py", line 916, in view_exists
   #     response.raise_for_status()
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/requests/models.py", line 1024, in raise_for_status
   #     raise HTTPError(http_error_msg, response=self)
   # requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://0.0.0.0:8181/v1/namespaces/default/views/bar
   
   # The above exception was the direct cause of the following exception:
   
   # Traceback (most recent call last):
   #   File "<stdin>", line 1, in <module>
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 336, in wrapped_f
   #     return copy(f, *args, **kw)
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 475, in __call__
   #     do = self.iter(retry_state=retry_state)
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 376, in iter
   #     result = action(retry_state)
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 398, in <lambda>
   #     self._add_action_func(lambda rs: rs.outcome.result())
   #   File "/Users/shivgupta/.pyenv/versions/3.9.16/lib/python3.9/concurrent/futures/_base.py", line 439, in result
   #     return self.__get_result()
   #   File "/Users/shivgupta/.pyenv/versions/3.9.16/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
   #     raise self._exception
   #   File "/Users/shivgupta/projects/iceberg-python/venv/lib/python3.9/site-packages/tenacity/__init__.py", line 478, in __call__
   #     result = fn(*args, **kwargs)
   #   File "/Users/shivgupta/projects/iceberg-python/pyiceberg/catalog/rest.py", line 918, in view_exists
   #     self._handle_non_200_response(exc, {})
   #   File "/Users/shivgupta/projects/iceberg-python/pyiceberg/catalog/rest.py", line 472, in _handle_non_200_response
   #     raise exception(response) from exc
   # pyiceberg.exceptions.BadRequestError: RESTError 400: Could not decode json payload: 
   ```
   
   Note, I used the [tabulario/iceberg-rest](https://hub.docker.com/r/tabulario/iceberg-rest) image to spin up a REST catalog server locally


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "sungwy (via GitHub)" <gi...@apache.org>.
sungwy commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2439077800

   Hi @shiv-io - thank you for putting together this PR! 
   
   > When I tested catalog.view_exists('default.bar') with a local REST catalog, I got the following exception. This also occurs with the existing catalog.table_exists() method. Is this expected?
   
   Yes, we have seen issues with specific implementations of the REST Catalog exhibiting issues with certain endpoints. Which REST Catalog implementation/image are you using to run your local test?


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu merged PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "shiv-io (via GitHub)" <gi...@apache.org>.
shiv-io commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2484508752

   @sungwy just bumping this in case this fell off your radar!


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "shiv-io (via GitHub)" <gi...@apache.org>.
shiv-io commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2463458916

   @sungwy thanks for reviewing! Let me know if there's anything else. I noticed we don't yet have docs for  `list_views` (#817) and `drop_views` (#820), btw.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "sungwy (via GitHub)" <gi...@apache.org>.
sungwy commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2606139140

   This looks good to me @shiv-io ! Thank you very much for including the integration test to test the API :)
   
   Could we run `make lint` to make the CI pass? Other than that, this looks good to be merged!


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "shiv-io (via GitHub)" <gi...@apache.org>.
shiv-io commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2600976666

   Makes sense, @sungwy -- thanks! Added the test, let me know if that looks good


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "shiv-io (via GitHub)" <gi...@apache.org>.
shiv-io commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2599777169

   @sungwy I'm seeing that the /v1/namespaces/default/views doesn't return any views. How would I go about adding an integration test for `view_exists` given pyiceberg currently doesn't support create view? Appreciate any direction here in case I'm missing something


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "shiv-io (via GitHub)" <gi...@apache.org>.
shiv-io commented on PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#issuecomment-2439162592

   @sungwy I used [tabulario/iceberg-rest](https://hub.docker.com/r/tabulario/iceberg-rest) image to spin up a REST catalog server locally to test with


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] Add `view_exists` method to REST Catalog [iceberg-python]

Posted by "sungwy (via GitHub)" <gi...@apache.org>.
sungwy commented on code in PR #1242:
URL: https://github.com/apache/iceberg-python/pull/1242#discussion_r1822580115


##########
tests/catalog/test_rest.py:
##########
@@ -450,6 +450,28 @@ def test_list_views_404(rest_mock: Mocker) -> None:
     assert "Namespace does not exist" in str(e.value)
 
 
+def test_view_exists_204(rest_mock: Mocker) -> None:
+    namespace = "examples"
+    view = "some_view"
+    rest_mock.head(
+        f"{TEST_URI}v1/namespaces/{namespace}/views/{view}",
+        status_code=204,
+        request_headers=TEST_HEADERS,
+    )
+    catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN)
+    assert catalog.view_exists((namespace, view))
+
+def test_view_exists_404(rest_mock: Mocker) -> None:
+    namespace = "examples"
+    view = "some_view"
+    rest_mock.head(
+        f"{TEST_URI}v1/namespaces/{namespace}/views/{view}",

Review Comment:
   Could we add a test case here for a multi-level namespace as well? 



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org