Introduction to Apache Airflow in Python
Mike Metzger
Data Engineer

{{ ... }} represents a template substitution
logical_date: When a Dag run occursds: The logical_date in YYYY-MM-DD formatlogical_date.year, logical_date.month, logical_date.day: Access the date componentsparams: The runtime parameters of the Dag runmacros.ds_add: Allows date calculations@dag(dag_id=`sales_etl`, on_failure_callback=SmtpNotifier( to='[email protected]', from_email='[email protected]',subject='sales_etl on {{ logical_date }} has failed!' ) )
ds (logical_date in YYYY-MM-DD )macros.ds_addfilewatcher = FileSensor(
task_id="wait_for_files",
filepath="/data/{{ macros.ds_add(ds, -1) }}/input.csv",
...
)
ds is 2026-04-30, the filepath would be /data/2026-04-29/input.csv
Introduction to Apache Airflow in Python