-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing namespace_exists function on the REST Catalog #1434
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I didn't know that spaces are allowed :D
Thanks for the contribution, @AhmedNader42 ! |
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