You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement iterator to lazily go through the paged response #3365
Recently the support for paged response was added to the list-view operationr: #3349. Right now it will just iterate over all the pages, instead it would be good to see if we can call the next page lazily to avoid many network calls: #3349 (comment)
I suggest discussing and reaching a consensus before beginning your work. This change may become unnecessary once we implement the page-size option in #3377.
#3377 is merged, thanks! An iterator might still be useful here to lazily fetch pages on the client side. page-size only controls the size of each individual response, not when or whether subsequent pages are fetched. Without an iterator, the client eagerly requests all pages upfront, even if the caller only needs the first few results.
I think we need to revive #2172. This is a breaking change when it comes to the returned types, but I think that's it. We might want to double check for len if that works the same way.
Iterators don't have a len method, so it would throw an error.
What would we think about creating our own list? That way, we can simply add in pagination ourselves while keeping the list syntax. Here's some quick example code (I think this would work)
class PaginationList(list):
# The list stores a token + callback to fetch new results.
self._pagination_token = ""
self._pagination_callback: Callable = None
# Calls the next page
# If pagination has no results, list will be set to empty.
def next_page() -> None:
# Example
tables: PaginationList = catalog.list_tables()
while len(tables) > 0:
for table in tables:
print(table)
tables.next_page()
Activity
harishkesavarao commentedon May 17, 2026
Is this open for me to work on? I would like to work on it if so.
ebyhr commentedon May 17, 2026
I suggest discussing and reaching a consensus before beginning your work. This change may become unnecessary once we implement the
page-sizeoption in #3377.kevinjqliu commentedon May 24, 2026
#3377 is merged, thanks! An iterator might still be useful here to lazily fetch pages on the client side.
page-sizeonly controls the size of each individual response, not when or whether subsequent pages are fetched. Without an iterator, the client eagerly requests all pages upfront, even if the caller only needs the first few results.Fokko commentedon May 25, 2026
I think we need to revive #2172. This is a breaking change when it comes to the returned types, but I think that's it. We might want to double check for
lenif that works the same way.rambleraptor commentedon May 26, 2026
Iterators don't have a
lenmethod, so it would throw an error.What would we think about creating our own list? That way, we can simply add in pagination ourselves while keeping the list syntax. Here's some quick example code (I think this would work)
Fix: implement lazy pagination iterator for catalog list methods (apa…
Fokko commentedon Jun 6, 2026
Yes, I've also stumbled upon it in #2172 (comment)
I think #3454 is the right approach, this way we don't have to introduce any breaking changes.