Get gbq table schema into python list

PHOTO EMBED

Sun Mar 20 2022 20:13:39 GMT+0000 (UTC)

Saved by @jmbenedetto #python

from google.cloud import bigquery

# Construct a BigQuery client object.
client = bigquery.Client(credentials=credentials)

# TODO(developer): Set table_id to the ID of the model to fetch.
table_id = 'raw_engagement.users_landmarks'

table = client.get_table(table_id)  # Make an API request.

table_schema = [{'name':bqfield.name,'type':bqfield.field_type,'mode':bqfield.mode} for bqfield in table.schema]
content_copyCOPY

Adjust the required metadata