Skip to content

Instantly share code, notes, and snippets.

@super-eben
Created March 12, 2019 07:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save super-eben/dcfa4420c419331e5a12a8b23e0a088c to your computer and use it in GitHub Desktop.
Save super-eben/dcfa4420c419331e5a12a8b23e0a088c to your computer and use it in GitHub Desktop.
Test DAG for the SuperQueryOperator
from datetime import timedelta, datetime
import json
from airflow import DAG
from airflow.operators.dummy_operator import DummyOperator
from airflow.operators.python_operator import PythonOperator
from airflow.operators.mysql_operator import MySqlOperator
from airflow.operators import DynamodbToBigqueryOperator
from airflow.operators import SuperQueryOperator
from airflow.hooks.mysql_hook import MySqlHook
TEST_SQL = """#standardSQL
SELECT COUNT(*) FROM `yourproject.yourdataset.yourtable`;
"""
default_args = {
"owner": "yooryourcompany",
"depends_on_past": True,
"start_date": datetime(2019, 3, 1), #start after this date
"email": ["you@yourcompany.io"],
"email_on_failure": True,
"email_on_retry": False,
"retries": 3,
"retry_delay": timedelta(minutes=1),
}
schedule_interval = "@once" # Run just once
dag = DAG("superquery_connection_test",
default_args=default_args,
schedule_interval=schedule_interval)
t_start = DummyOperator(task_id="start_here", dag=dag)
t_check_superquery_connection = SuperQueryOperator(
task_id="connect_to_superquery_proxy",
sql=TEST_SQL,
database="",
explain=True,
dag=dag
)
# The DAG flow
t_start >> t_check_superquery_connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment