首页 > 解决方案 > 将查询结果移动到另一个位置

问题描述

我在 python 文件中定义了一个 Airflow DAG。想对美国本地化的 bigquery 公共数据运行查询,并将结果存储在我在欧盟位置的 biquery 中。在一个 DAG 步骤中管理操作会很棒。

使用如下代码,但它会引发错误:将位置设置为美国,但输出数据集位于另一个位置。

get_data = bigquery_operator.BigQueryOperator(
  ...
  location='US',
  sql="""
    select ...
    from 'bigquery-public-data.new_tork_taxi_trips.tlc_green_trips_2018'''
  """,
  destination_dataset_table=<my-proj>.<my-dataset>.<my-table>,
  ...
)

标签: google-cloud-platformairflow

解决方案


请参阅Temporary and permanent tablesBigQuery 文档,当您将查询结果写入永久表时,您要查询的表必须与包含目标表的数据集位于同一位置。

参考:https ://cloud.google.com/bigquery/docs/managing-tables#limitations_on_copying_tables


推荐阅读