-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Currently, the maximum number of rows that you can get when iterating using fetchmany, fetchall or fetchone is limited by arraysize.
I see that those methods are using iterator returned by _query_data.fetch_data() with max_results set to arraysize
https://github.com/GoogleCloudPlatform/google-cloud-python/blob/36304f7448677cff2f89558ef87c374e904a0492/bigquery/google/cloud/bigquery/dbapi/cursor.py#L171-L172
However, shouldn't it automatically fetch the next page of results when we are finished iterating over the current batch of results? Otherwise, it makes it impossible to retrieve full results from the query without settingarraysize to an arbitrary large number.
Here is what I've tried:
cursor.execute('SELECT * FROM dataset.table')
while True:
rows = cursor.fetchmany(5000)
if not rows:
break
for row in rows:
print(row)
cursor.execute('SELECT * FROM dataset.table')
row = cursor.fetchone()
while row:
print(row)
row = cursor.fetchone()
I am using google-cloud-bigquery 0.26.0
Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the BigQuery API.Issues related to the BigQuery API.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.