Reputation: 3514
I'm trying to use a .sql
file saved on Google Cloud Storage to query BigQuery
I'm trying with the bq
command docs without success.
bq query --use_legacy_sql=false < gs://bucket/path-to-file/file.sql
Is the command misused ?
Upvotes: 0
Views: 1013
Reputation: 330
Use can use both:
bq query --nouse_legacy_sql
and
bq query --use_legacy_sql=false
Check whether you have access to that bucket in Storage and copy the file to a local folder if it's not so large:
gsutil cp gs://bucket/path-to-file/file.sql .
Try to apply that file
bq query --nouse_legacy_sql << file.sql
You can try such trick if the file isn't large:
bq query --nouse_legacy_sql "$(gsutil cat gs://bucket/path-to-file/file.sql)"
Upvotes: 1
Reputation: 172994
The file with script should be local to your gcloud instance
Assuming file.sql is in your working directory - below example would work
bq query --use_legacy_sql=false < file.sql
So, in your case you need to use gsutil to first load file.sql from GCS to your directory
gsutil cp gs://bucket/path-to-file/file.sql .
bq query --use_legacy_sql=false < file.sql
Upvotes: 0