Skip to content

Commit

Permalink
Merge pull request #184 from hraban/bq-empty-result
Browse files Browse the repository at this point in the history
BQ: Empty array when no results
  • Loading branch information
Jon Wayne Parrott committed Feb 16, 2016
2 parents 150439c + ad6ebb3 commit 9b46c42
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bigquery/api/sync_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,21 @@ def main(project_id, query, timeout, num_retries):

# [START paging]
# Page through the result set and print all results.
results = []
page_token = None

while True:
page = bigquery.jobs().getQueryResults(
pageToken=page_token,
**query_job['jobReference']).execute(num_retries=2)

print(json.dumps(page['rows']))
results.extend(page.get('rows', []))

page_token = page.get('pageToken')
if not page_token:
break

print(json.dumps(results))
# [END paging]
# [END run]

Expand Down

0 comments on commit 9b46c42

Please sign in to comment.