Google Cloud BigQuery 到 BigQuery 傳輸 Operator¶
Google Cloud BigQuery 是 Google Cloud 提供的無伺服器資料倉庫服務。此 Operator 可用於將資料從一個 BigQuery 表複製到另一個 BigQuery 表。
先決任務¶
要使用這些 Operators,您必須執行以下幾項操作:
使用 Cloud Console 選擇或建立 Cloud Platform 專案。
為您的專案啟用計費,如 Google Cloud 文件中所述。
啟用 API,如 Cloud Console 文件中所述。
透過 pip 安裝 API 庫。
pip install 'apache-airflow[google]'詳細資訊請參閱 安裝。
Operator¶
使用 BigQueryToBigQueryOperator Operator 可以將資料從一個 BigQuery 表複製到另一個表。
將 Jinja 模板與 source_project_dataset_tables, destination_project_dataset_table, labels, impersonation_chain 一起使用,以動態定義值。
您可以包含多個源表,並定義 write_disposition 和 create_disposition。更多資訊請參閱上面的連結。
複製 BigQuery 表¶
以下 Operator 可將資料從一個或多個 BigQuery 表複製到另一個表。
tests/system/google/cloud/bigquery/example_bigquery_to_bigquery.py
copy_selected_data = BigQueryToBigQueryOperator(
task_id="copy_selected_data",
source_project_dataset_tables=f"{DATASET_NAME}.{ORIGIN}",
destination_project_dataset_table=f"{DATASET_NAME}.{TARGET}",
)
參考資料¶
更多資訊請參閱: