Implementing namespace_exists function on the REST Catalog#1434
Implementing namespace_exists function on the REST Catalog#1434kevinjqliu merged 4 commits intoapache:mainfrom
Conversation
- Added the relevant unit tests
| def test_namespace_exists_200(rest_mock: Mocker) -> None: | ||
| rest_mock.head( | ||
| f"{TEST_URI}v1/namespaces/fokko", | ||
| status_code=200, | ||
| request_headers=TEST_HEADERS, | ||
| ) | ||
| catalog = RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN) | ||
|
|
||
| assert catalog.namespace_exists("fokko") |
There was a problem hiding this comment.
nit: the tests here are only verifying against the mock response.
it would be great to test against the actual REST catalog in integration tests.
i noticed that does not exist right now, perhaps we can start a tests/integration/test_rest_catalog.py
There was a problem hiding this comment.
Yes, Good point! I was looking for how to properly test this but didn't find any tests touching the REST Catalog. I thought it was a bit out of scope for the initial issue to add a new integration test flow.
Maybe we should open a new enhancement and add the details to it to implement a new integration test for REST Catalog at tests/integration/test_rest_catalog.py like you mentioned. Thoughts? I'm willing to pick it up
|
Hi @AhmedNader42 - thank you very much for picking up this issue and getting a working solution up already! I'm in agreement with @kevinjqliu 's comment, that it would be great to have an integration test as well, and I think it is well within the scope of this PR. https://github.com/apache/iceberg-python/blob/main/tests/integration/test_reads.py already uses |
|
Hello @sungwy, Thank you for pointing that out! Sounds good to me. I'll work on adding some test cases for REST Catalog in test_reads.py
|
|
I created a new file for REST Catalog integration tests |
kevinjqliu
left a comment
There was a problem hiding this comment.
LGTM! Thank you for adding the integration test for rest catalog, much needed :)
I double-checked with namespaceExists in the REST spec, everything looks good.
Similar to tableExists, we're including 200 status code as a convenience. I'll see if we can add this to the spec itself
|
@AhmedNader42 looks like the RAT check failed. For new files, we need to include the ASF license on top, like iceberg-python/tests/catalog/test_rest.py Lines 1 to 16 in ceffe08 |
|
|
||
| from pyiceberg.catalog.rest import RestCatalog | ||
|
|
||
| TEST_NAMESPACE_IDENTIFIER = "TEST NS" |
There was a problem hiding this comment.
Hmm, I didn't know that spaces are allowed :D
|
Thanks for the contribution, @AhmedNader42 ! |
* - Added the namespace_exists function in the RESTCatalog - Added the relevant unit tests * - Removed docstring to match other namespace functions * - Added integration test for REST Catalog namespace_exists functionality * - Added ASF license to test_rest_catalog.py to recover from failing test
As per #1430 I have added the namespace_exists functionality for REST Catalog.
Here's an example usage similar to the table_exists function of the same class
Please review the changes