Skip to content

Conversation

jayceslesar
Copy link
Contributor

Rationale for this change

We want to support pagination and we need to be able to return iterators to do so.

See #2158 for more context

Are these changes tested?

Existing tests were modified

Are there any user-facing changes?

yes, this is user facing and breaking but overall an improvement.

Copy link
Contributor

@rambleraptor rambleraptor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome! Thanks for doing it. I've got one code question and then a versioning question:

Do we need to wait for 1.0 to change these APIs? I'm hoping the answer will be no.

Comment on lines +575 to +576
if tables := list(self.list_tables(namespace)):
raise NamespaceNotEmptyError(f"Namespace {namespace_str} is not empty. {len(list(tables))} tables exist.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we (eventually) handle pagination tokens, I believe this will cause the process to consume the entire paginated list. If it's a long list, that'll require a lot of server calls to fetch all of the tables.

If that's true, what if we did this instead?

Suggested change
if tables := list(self.list_tables(namespace)):
raise NamespaceNotEmptyError(f"Namespace {namespace_str} is not empty. {len(list(tables))} tables exist.")
tables = self.list_tables(namespace)
try:
next(tables)
raise NamespaceNotEmptyError(f"Namespace {namespace_str} is not empty. {len(list(tables))} tables exist.")
except StopIteration:
pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, maybe it makes the most sense to make a little helper function here for if a namespace is empty or not? can do that in a different MR but i dont know if thats an official method upstream https://github.com/search?q=repo%3Aapache%2Ficeberg%20namespacenotempty&type=code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants