Use this script to get the BQ table schema in a format that can be used to create a new BQ table.

Home   »   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: :."
	exit 1
fi


if $(echo "" | jq .); then
  bq show --format=prettyjson p$1 | jq '.schema.fields'
else
  echo "Please install jq."
  exit 1
fi

Leave a Reply

Your email address will not be published. Required fields are marked *