Skip to content

Instantly share code, notes, and snippets.

@ngollperrier
Last active October 31, 2018 15:48
Show Gist options
  • Save ngollperrier/f3ca64e93deef34cdbdf4c2246c75814 to your computer and use it in GitHub Desktop.
Save ngollperrier/f3ca64e93deef34cdbdf4c2246c75814 to your computer and use it in GitHub Desktop.
# The connection ID to the datawarehouse DB (must match the connection
# handler defined in airflow for the data source)
target_db = 'mini-warehouse-db'
# A simple sensor checking wether clickstream data is present
# for the day following the execution_date of the DAG Run
sensor_query_template = '''
SELECT TRUE
FROM clickstream
WHERE click_timestamp::DATE >= '{{ execution_date + macros.timedelta(days=1) }}'::DATE
LIMIT 1
'''
# A sensor task using a SqlSensor operator
sensor_task = SqlSensor(
task_id='check_data_avail',
conn_id=target_db,
sql=sensor_query_template,
poke_interval=30,
timeout=3600,
dag=dag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment