使用python将BigQuery表数据导出到具有where子句的Google Cloud Storage

Sau*_*wal 6 python google-cloud-storage google-bigquery

我想将表格数据从BigQuery导出到Google Cloud Storage。问题是,我需要从date1到date2的数据,而不是整个表的数据。

extract_job = client.extract_table(
    table_ref,
    destination_uri,
    # Location must match that of the source table.
    location='US')  # API request
extract_job.result()  
Run Code Online (Sandbox Code Playgroud)

这就是我在Google云端帮助中找到的内容。没有空间使用where子句添加查询或限制数据。

Lun*_*ast 2

使用您提供的代码(遵循本文档),您只能将整个表导出到 GCS,而不能导出查询结果。

或者,您可以下载查询结果并将其保存到本地文件,然后上传到 GCS。或者更简单的是,将查询结果保存到新的 BigQuery 表,并使用您使用的代码将该新表完全导出到 GCS。