Skip to content

Commit

Permalink
Added default NULLABLE mode when bigquery does not provide one
Browse files Browse the repository at this point in the history
  • Loading branch information
abroglesc committed Nov 9, 2020
1 parent 7afdf41 commit 96ca4ae
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions bigquery_schema_generator/generate_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,23 +757,26 @@ def bq_type_to_entry_type(type):

def bq_schema_field_to_entry(field):
type = bq_type_to_entry_type(field['type'])
# In some cases with nested fields within a record, bigquery does not
# populate a mode field. We will assume this is NULLABLE in this case
mode = field.get('mode', 'NULLABLE')
# maintain order of info fields
if type == 'RECORD':
info = OrderedDict([
('fields', bq_schema_to_map(field['fields'])),
('mode', field['mode']),
('mode', mode),
('name', field['name']),
('type', type),
])
else:
info = OrderedDict([
('mode', field['mode']),
('mode', mode),
('name', field['name']),
('type', type),
])
return OrderedDict([
('status', 'hard'),
('filled', field['mode'] != 'NULLABLE'),
('filled', mode != 'NULLABLE'),
('info', info),
])

Expand Down

0 comments on commit 96ca4ae

Please sign in to comment.