BigQuery bq extract examples

Use bq extract command to export table data to a file in Cloud Storage

Export BigQuery table to CSV file:

bq extract --compression=GZIP --destination_format=CSV 
myDataset.myTable gs://my-bucket/myFile*.csv.gzip

Export BigQuery table to Parquet file:

bq extract --compression=SNAPPY --destination_format=PARQUET 
myDataset.myTable gs://my-bucket/myFile*.parquet

Export BigQuery table to AVRO file:

bq extract --compression=SNAPPY --destination_format=AVRO
myDataset.myTable gs://my-bucket/myFile*.avro

Options:

  • --field_delimiter=DELIMITER : For CSV exports, specifies the character that marks the boundary between columns in the output file. The delimiter can be any single-byte character. You can use \t or tab to specify tab delimiters
  • --print_header={true|false} : To suppress printing header rows for formats that have headers, set to false. The default is true