RowIterator is not actually an Iterator, it is an Iterable. Either it should be an Iterator, or it should be renamed? At this point, but maybe api_core.Iterator could implement both Iterable and Iterator? Or maybe the documentation could specify this? This is very very minor, since most use will be in a for loop, so maybe this should be closed as "won't fix", but it did confuse me when trying to figure out how to get the next_page_token as early as possible. I need to call iter(row_it) because `RowIterator is not actually an iterator ... it is an iterable!
Example code
from google.cloud import bigquery
bq_client = bigquery.Client()
table = bq_client.dataset('tmp').table('supply_house_ramp9_NTM_split2')
row_iterator = bq_client.list_rows(table, max_results=10)
print('row_iterator:', row_iterator)
# fix: next(iter(row_iterator))
next(row_iterator)
Output:
row_iterator: <google.cloud.bigquery.table.RowIterator object at 0x10a44d090>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'RowIterator' object is not an iterator
Expected output:
Return the first row of the table, since it is called an iterator, you should be able to pass it to next()
Environment details
OS: Any
Python version: Python 3.7.4
google-cloud-bigquery version: 1.20.0
RowIterator is not actually an Iterator, it is an Iterable. Either it should be an Iterator, or it should be renamed? At this point, but maybe
api_core.Iteratorcould implement both Iterable and Iterator? Or maybe the documentation could specify this? This is very very minor, since most use will be in aforloop, so maybe this should be closed as "won't fix", but it did confuse me when trying to figure out how to get thenext_page_tokenas early as possible. I need to calliter(row_it)because `RowIterator is not actually an iterator ... it is an iterable!Example code
Output:
Expected output:
Return the first row of the table, since it is called an iterator, you should be able to pass it to
next()Environment details
OS: Any
Python version:
Python 3.7.4google-cloud-bigquery version:
1.20.0