Skip to content

Instantly share code, notes, and snippets.

@itroulli
Created May 6, 2021 11:51
Show Gist options
  • Select an option

  • Save itroulli/0bcd28121982e353ac5609aaef0bc64a to your computer and use it in GitHub Desktop.

Select an option

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.
#!/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