- List all datasets in a project
bq ls bigquery-public-data
2. List all tables within a dataset
select table_name from `bigquery-public-data`.samples.INFORMATION_SCHEMA.TABLES
3. List schema of a table
select * from `bigquery-public-data`.samples.INFORMATION_SCHEMA.TABLES where table_name = 'natality'
aliter:
bq show bigquery-public-data:samples.shakespeare
to get as json:
$ bq --format=json show publicdata:samples.natality
4. Create a dataset:
$ bq mk babynames
5. Get job details. Two ways of doing this. Method1: use bq show command:
$ bq --project_id=xxx --location=${LOCATION} show --job=true ${JOB_ID}
Method2: use REST endpoint. This will display much more data than bq show command:
JOBID=$1 # CHANGE
access_token=$(gcloud auth application-default print-access-token)
PROJECT=$(gcloud config get-value project)
curl --silent \
-H "Authorization: Bearer $access_token" \
-X GET \
"https://www.googleapis.com/bigquery/v2/projects/$PROJECT/jobs/${JOBID}?location=${LOCATION}"