Invalid extract destination while exporting BigQuery table to a CSV file

You can export a BigQuery table to CSV file and store in a google cloud storage bucket. While exporting the data make sure you provide the complete GCS bucket path as well the filename with extension. Otherwise you may stumble on the below error message

Invalid extract destination URI 'gs://bucket_name'. Must be a valid Google Cloud 
Storage path and filename/pattern

Solution:

  • Make sure you specify gs:// prefix to the GCS bucket name
  • Mention the extract file name as well with extension
  • If the table is huge (over 1 GB) make sure to provide a wildcard character, so google can split into multiple files

You need to give the extract a file name too:

gs://test_bucket/filename.csv

gs://test_bucket/filename.*.csv
bq extract --compression GZIP 'mydataset.mytable' gs://example-bucket/myfile.csv

victor

posted on 01 Sep 20

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds