我需要将bigquery数据(使用一些过滤器选择)加载到json格式的gcs存储桶中,然后进行压缩。当前的气流操作员正在将表格从bq导出到gcs,有没有办法将一些带有过滤器的选择数据从BQ推送到GCS?
发布于 2021-01-20 00:11:37
您可以只设置BigQueryToGCSOperator的compression参数
from airflow.providers.google.cloud.transfers.bigquery_to_gcs import BigQueryToGCSOperator
bigquery_to_gcs = BigQueryToGCSOperator(
task_id="bigquery_to_gcs",
source_project_dataset_table="DATASET_NAME.TABLE",
destination_cloud_storage_uris=["gs://folder/your_file"],
compression='gzip'
)发布于 2021-01-20 00:20:40
对于这个问题,在BigQuery中有一个使用EXPORT DATA语句的纯SQL解决方案。请参见以下示例:
EXPORT DATA
OPTIONS (
compression = GZIP,
format = JSON,
uri = 'gs://bucket/path/file_*'
) AS
-- query_statement
select 1 as x, 2 as y;从GCS下载文件并从arhive中提取后,我获得了以下数据:
{"x":"1","y":"2"}https://stackoverflow.com/questions/65795028
复制相似问题