Created
May 6, 2021 11:51
-
-
Save itroulli/0bcd28121982e353ac5609aaef0bc64a to your computer and use it in GitHub Desktop.
Use this script to get the BQ table schema in a format that can be used to create a new BQ table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if [ -z $1 ]; then | |
| echo "Provide a BigQuery table spec, in the format of: <PROJECT_ID>:<DATASET_ID>.<TABLE_ID>" | |
| exit 1 | |
| fi | |
| if $(echo "" | jq .); then | |
| bq show --format=prettyjson p$1 | jq '.schema.fields' | |
| else | |
| echo "Please install jq." | |
| exit 1 | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment