Google Cloud BigQuery 到 Google Cloud Storage 传输运算符

Google Cloud BigQuery 是 Google Cloud 提供的无服务器数据仓库服务。Google Cloud Storage (GCS) 是一种用于存储非结构化数据的托管服务。此运算符可用于将数据从 BigQuery 表导出到 Cloud Storage 存储桶中的文件。

前提任务

要使用这些运算符,您必须执行以下操作:

运算符

通过 BigQueryToGCSOperator 运算符执行从 BigQuery 到 GCS 的表导出。

使用 Jinja 模板化(Jinja templating) 配合 source_project_dataset_tabledestination_cloud_storage_urisexport_formatlabelsimpersonation_chainjob_id 等参数来动态定义值。

您可以定义多个目标 URI,以及 compressionexport_format 等其他设置。更多信息请参考以上链接。

导出表

以下运算符将 BigQuery 表导出到 GCS。

tests/system/google/cloud/bigquery/example_bigquery_to_gcs.py

bigquery_to_gcs = BigQueryToGCSOperator(
    task_id="bigquery_to_gcs",
    source_project_dataset_table=f"{DATASET_NAME}.{TABLE}",
    destination_cloud_storage_uris=[f"gs://{BUCKET_NAME}/{BUCKET_FILE}"],
)

参考

更多信息,请参阅:

此条目有用吗?