'Extract BigQuery partitioned table

Is there a way to extract the complete BigQuery partitioned table with one command so that data of each partition is extracted into a separate folder of the format part_col=date_yyyy-mm-dd

Since Bigquery partitioned table can read files from the hive type partitioned directories, is there a way to extract the data in a similar way. I can extract each partition separately, however that is very cumbersome when i an extracting a lot of partitions



Solution 1:[1]

Set the project as test_dataset using gcloud init before running the below command.

bq extract --destination_format=CSV 'test_partitiontime$20210716' gs://testbucket/20210716/test*.csv

This will create a folder with the name 20210716 inside testbucket and write the file there.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bertold Kolics