Skip to content

fix(samples): catch EOFError in quickstart #708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions samples/quickstart/quickstart.py
Original file line number Diff line number Diff line change
@@ -75,9 +75,14 @@ def main(project_id="your-project-id", snapshot_millis=0):
names = set()
states = set()

for row in rows:
names.add(row["name"])
states.add(row["state"])
# fastavro returns EOFError instead of StopIterationError starting v1.8.4.
# See https://github.com/googleapis/python-bigquery-storage/pull/687
try:
for row in rows:
names.add(row["name"])
states.add(row["state"])
except EOFError:
pass

print("Got {} unique names in states: {}".format(len(names), ", ".join(states)))
# [END bigquerystorage_quickstart]