Copy partitioned table schema to another table

Use the gcloud bq cli tool

1) export the source table schema to json file. Each item only requires name and type fields.

bq show --schema --format=prettyjson projectId:Dataset.table > emailschema.json

https://cloud.google.com/bigquery/docs/schemas#specify-schema-manual-cli

2) Create the table in destination as partitioned

bq mk --table --schema ./emailschema.json --time_partitioning_type DAY projectId:dataset.table

https://cloud.google.com/bigquery/docs/creating-column-partitions

Comments

Popular posts from this blog

Using moment.js

Changing BigQuery table field names