rambleraptor commented on code in PR #2172:
URL: https://github.com/apache/iceberg-python/pull/2172#discussion_r2360714616
##########
pyiceberg/catalog/sql.py:
##########
@@ -572,8 +572,8 @@ def drop_namespace(self, namespace: Union[str, Identifier])
-> None:
raise NoSuchNamespaceError(f"Namespace does not exist:
{namespace}")
namespace_str = Catalog.namespace_to_string(namespace)
- if tables := self.list_tables(namespace):
- raise NamespaceNotEmptyError(f"Namespace {namespace_str} is not
empty. {len(tables)} tables exist.")
+ if tables := list(self.list_tables(namespace)):
+ raise NamespaceNotEmptyError(f"Namespace {namespace_str} is not
empty. {len(list(tables))} tables exist.")
Review Comment:
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?
```suggestion
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
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]