unitycatalog / unitycatalog

Open, Multi-modal Catalog for Data & AI
https://unitycatalog.io/
Apache License 2.0
1.86k stars 250 forks source link

List tables API gives one more (empty) page and terminates with empty string page_token instead of null #21

Open jaychia opened 2 weeks ago

jaychia commented 2 weeks ago

When performing a tables.list operation, it seems that the server returns the empty string "" instead of None as documented in the spec.

image

On a default run of unity catalog:

!pip install unitycatalog

import unitycatalog

client = unitycatalog.Unitycatalog(base_url="http://127.0.0.1:8080/api/2.1/unity-catalog/")
response = client.tables.list(catalog_name="unity", schema_name="default")

# assert response.next_page_token is None, f"This will fail, with a non-empty token: {response.next_page_token}"

response = client.tables.list(catalog_name="unity", schema_name="default", page_token=response.next_page_token)
# assert len(response.tables) > 0, "This will fail, because response has no tables"

# assert response.next_page_token is None, f"This will fail, with empty token: {response.next_page_token}"

This led to an unexpected infinite loop on my client-side code! Expected behavior: return null for the token when the page stream is exhausted.

abrassel commented 2 weeks ago

Mind if I take this issue?

tdas commented 2 weeks ago

@abrassel oh yes! please take this up and make a PR! thank you so much in advance!

abrassel commented 2 weeks ago

thank you! @tdas can you assign it to me?

abrassel commented 2 weeks ago

@jaychia https://github.com/unitycatalog/unitycatalog/pull/70

vikrantpuppala commented 4 days ago

Fixed by #70. @tdas we can mark this issue as resolved.