Fokko commented on code in PR #2172:
URL: https://github.com/apache/iceberg-python/pull/2172#discussion_r2593957290


##########
pyiceberg/catalog/hive.py:
##########
@@ -719,33 +720,33 @@ def list_tables(self, namespace: str | Identifier) -> 
list[Identifier]:
             namespace: Database to list.
 
         Returns:
-            List[Identifier]: list of table identifiers.
+            Iterator[Identifier]: iterator of table identifiers.
 
         Raises:
             NoSuchNamespaceError: If a namespace with the given name does not 
exist, or the identifier is invalid.
         """
         database_name = self.identifier_to_database(namespace, 
NoSuchNamespaceError)
         with self._client as open_client:
-            return [
+            yield from [
                 (database_name, table.tableName)
                 for table in open_client.get_table_objects_by_name(
                     dbname=database_name, 
tbl_names=open_client.get_all_tables(db_name=database_name)
                 )
                 if table.parameters.get(TABLE_TYPE, "").lower() == ICEBERG
             ]
 
-    def list_namespaces(self, namespace: str | Identifier = ()) -> 
list[Identifier]:
+    def list_namespaces(self, namespace: str | Identifier = ()) -> 
Iterator[Identifier]:
         """List namespaces from the given namespace. If not given, list 
top-level namespaces from the catalog.
 
         Returns:
-            List[Identifier]: a List of namespace identifiers.
+            Iterator[Identifier]: an iterator of namespace identifiers.
         """
         # Hierarchical namespace is not supported. Return an empty list
         if namespace:
-            return []
+            return iter([])

Review Comment:
   I see. The reason I ask is because the `iter` doesn't allow for `len`:
   
   ```
   Python 3.14.1 (main, Dec  2 2025, 12:51:37) [Clang 17.0.0 
(clang-1700.4.4.1)] on darwin
   Type "help", "copyright", "credits" or "license" for more information.
   >>> len(iter([1,2,3]))
   Traceback (most recent call last):
     File "<python-input-0>", line 1, in <module>
       len(iter([1,2,3]))
       ~~~^^^^^^^^^^^^^^^
   TypeError: object of type 'list_iterator' has no len()
   >>> len([1,2,3])
   3
   ```



##########
pyiceberg/catalog/hive.py:
##########
@@ -719,33 +720,33 @@ def list_tables(self, namespace: str | Identifier) -> 
list[Identifier]:
             namespace: Database to list.
 
         Returns:
-            List[Identifier]: list of table identifiers.
+            Iterator[Identifier]: iterator of table identifiers.
 
         Raises:
             NoSuchNamespaceError: If a namespace with the given name does not 
exist, or the identifier is invalid.
         """
         database_name = self.identifier_to_database(namespace, 
NoSuchNamespaceError)
         with self._client as open_client:
-            return [
+            yield from [
                 (database_name, table.tableName)
                 for table in open_client.get_table_objects_by_name(
                     dbname=database_name, 
tbl_names=open_client.get_all_tables(db_name=database_name)
                 )
                 if table.parameters.get(TABLE_TYPE, "").lower() == ICEBERG
             ]
 
-    def list_namespaces(self, namespace: str | Identifier = ()) -> 
list[Identifier]:
+    def list_namespaces(self, namespace: str | Identifier = ()) -> 
Iterator[Identifier]:
         """List namespaces from the given namespace. If not given, list 
top-level namespaces from the catalog.
 
         Returns:
-            List[Identifier]: a List of namespace identifiers.
+            Iterator[Identifier]: an iterator of namespace identifiers.
         """
         # Hierarchical namespace is not supported. Return an empty list
         if namespace:
-            return []
+            return iter([])

Review Comment:
   I see. The reason I ask is because `iter` doesn't allow for `len`:
   
   ```
   Python 3.14.1 (main, Dec  2 2025, 12:51:37) [Clang 17.0.0 
(clang-1700.4.4.1)] on darwin
   Type "help", "copyright", "credits" or "license" for more information.
   >>> len(iter([1,2,3]))
   Traceback (most recent call last):
     File "<python-input-0>", line 1, in <module>
       len(iter([1,2,3]))
       ~~~^^^^^^^^^^^^^^^
   TypeError: object of type 'list_iterator' has no len()
   >>> len([1,2,3])
   3
   ```



-- 
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]

Reply via email to