You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/08/12 14:22:01 UTC

[GitHub] [airflow] nuclearpinguin commented on a change in pull request #5769: [AIRFLOW-4964] Add BigQuery Data Transfer Hook and Operator

nuclearpinguin commented on a change in pull request #5769: [AIRFLOW-4964] Add BigQuery Data Transfer Hook and Operator
URL: https://github.com/apache/airflow/pull/5769#discussion_r312950250
 
 

 ##########
 File path: airflow/contrib/example_dags/example_gcp_bigquery_dts.py
 ##########
 @@ -0,0 +1,128 @@
+# -*- coding: utf-8 -*-
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Example Airflow DAG that creates and deletes Bigquery data transfer configurations.
+"""
+import os
+import time
+
+from google.protobuf.json_format import ParseDict
+from google.cloud.bigquery_datatransfer_v1.types import TransferConfig
+
+import airflow
+from airflow import models
+from airflow.contrib.operators.gcp_bigquery_dts_operator import (
+    BigQueryCreateDataTransferOperator,
+    BigQueryDeleteDataTransferConfigOperator,
+    BigQueryDataTransferServiceStartTransferRunsOperator,
+)
+from airflow.contrib.sensors.gcp_bigquery_dts_sensor import (
+    BigQueryDataTransferServiceTransferRunSensor,
+)
+
+
+GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project")
+BUCKET_URI = os.environ.get(
+    "GCP_DTS_BUCKET_URI", "gs://cloud-ml-tables-data/bank-marketing.csv"
+)
+GCP_DTS_BQ_DATASET = os.environ.get("GCP_DTS_BQ_DATASET", "test_dts")
+GCP_DTS_BQ_TABLE = os.environ.get("GCP_DTS_BQ_TABLE", "GCS_Test")
+
+# [START howto_bigquery_dts_create_args]
+
+# In the case of Airflow, the customer needs to create a transfer
+# config with the automatic scheduling disabled and then trigger
+# a transfer run using a specialized Airflow operator
+schedule_options = {"disable_auto_scheduling": True}
 
 Review comment:
   Yes, it's done in hook's method `_disable_auto_scheduling`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services