8000 BigQuery : max_results changes page size not full list size · johnmanong/python-docs-samples@2db0c9c · GitHub
[go: up one dir, main page]

Skip to content

Commit 2db0c9c

Browse files
authored
BigQuery : max_results changes page size not full list size
Also, running a query is not "preferred" if you do want all the data. If you do run a query, you end up reading data from the destination table anyway.
1 parent f15c86a commit 2db0c9c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bigquery/cloud-client/snippets.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"""
2626

2727
import argparse
28+
import itertools
2829
import uuid
2930

3031
from google.cloud import bigquery
@@ -124,10 +125,9 @@ def list_rows(dataset_name, table_name, project=None):
124125
# Reload the table so that the schema is available.
125126
table.reload()
126127

127-
# Load at most 25 results. You can change the max_results argument to load
128-
# more rows from BigQuery, but note that this can take some time. It's
129-
# preferred to use a query.
130-
rows = list(table.fetch_data(max_results=25))
128+
# Load at most 25 results per page. You can change the max_results
129+
# argument to load more rows from BigQuery at a time.
130+
rows = list(itertools.islice(table.fetch_data(max_results=25), 25))
131131

132132
# Use format to create a simple table.
133133
format_string = '{!s:<16} ' * len(table.schema)

0 commit comments

Comments
 (0)
0