Skip to content

Commit

Permalink
Add handling of missing properties SchemaField.from_api_repr
Browse files Browse the repository at this point in the history
  • Loading branch information
alanbato committed Jan 15, 2018
1 parent ddaa9a0 commit 42db145
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bigquery/google/cloud/bigquery/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ def from_api_repr(cls, api_repr):
google.cloud.biquery.schema.SchemaField:
The ``SchemaField`` object.
"""
# Handle optional properties with default values
mode = api_repr.get('mode', 'NULLABLE')
fields = api_repr.get('fields', ())
return cls(
field_type=api_repr['type'].upper(),
fields=[cls.from_api_repr(f) for f in api_repr.get('fields', ())],
mode=api_repr['mode'].upper(),
fields=[cls.from_api_repr(f) for f in fields],
mode=mode.upper(),
name=api_repr['name'],
)

Expand Down

0 comments on commit 42db145

Please sign in to comment.