https://www.topgate.co.jp/gcp12-how-to-analyze-big-data-with-bigquery
https://cloud.google.com/bigquery/docs/quickstarts/load-data-bq?hl=ja
bq コマンドライン ツールは、Python をベースにした BigQuery 用のコマンドライン ツールです
bqコマンドはgcloud CLI に含まれる。
-- 1. 前作業
gcloud init
gcloud auth list
gcloud --version
gcloud projects create project01-9999999 \
--name="project01"
gcloud config list
gcloud config set project project01-9999999
gcloud config set compute/region asia-northeast1 --quiet
gcloud config set compute/zone asia-northeast1-a --quiet
gcloud beta billing accounts list
gcloud beta billing projects link project01-9999999 --billing-account=111111-111111-111111
gcloud services enable compute.googleapis.com --project project01-9999999
gcloud components update
-- 2. BigQuery API有効化
gcloud services list --enabled
gcloud services enable bigquery.googleapis.com \
--project project01-9999999
-- 3. ソースの公開データファイルをダウンロードする
wget https://www.ssa.gov/OACT/babynames/names.zip
unzip names.zip
ls -lh yob2010.txt
wc -l yob2010.txt
head yob2010.txt
-- 4. データセットを作成する
bq mk ds01
bq ls
-- 5. テーブルにデータを読み込む
bq load ds01.tab1 yob2010.txt name:string,gender:string,count:integer
bq ls ds01
bq show ds01.tab1
-- 6. テーブルデータをクエリする
bq query --use_legacy_sql=false \
'select count(*) from ds01.tab1;'
bq query --use_legacy_sql=false \
'select name, count
from ds01.tab1
where gender = "F"
order by count desc limit 5;'
-- 7. クリーンアップ
bq rm --recursive=true ds01
bq ls
gcloud projects list
gcloud projects delete project01-9999999