Skip to content

Instantly share code, notes, and snippets.

@mshakhomirov
Created October 20, 2019 18:02
Show Gist options
  • Save mshakhomirov/bed6b52b3dedbc2ad51e07ec42b2614b to your computer and use it in GitHub Desktop.
Save mshakhomirov/bed6b52b3dedbc2ad51e07ec42b2614b to your computer and use it in GitHub Desktop.
def create_schema_from_yaml(table_schema):
schema = []
for column in table_schema:
schemaField = bigquery.SchemaField(column['name'], column['type'], column['mode'])
schema.append(schemaField)
if column['type'] == 'RECORD':
schemaField._fields = create_schema_from_yaml(column['fields'])
return schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment