Airflow Filters are powerful tools that allow you to dynamically generate parameter values for your tasks at runtime. They enhance flexibility and reusability in your workflows.
Key Concepts
Jinja Templating: Airflow uses Jinja2 templating engine, allowing you to embed expressions within your DAG definition.
Context Variables: Airflow provides a set of predefined context variables accessible within Jinja templates, such as ds (date stamp), execution_date, dag_run, and task_instance.
Custom Filters: You can define your own custom filters to perform specific data transformations.
Commonly Used Filters
ds_add(days): Adds or subtracts days from a date string.
ds_format(input_format, output_format): Formats a date string from one format to another.
tojson: Converts a Python object to a JSON string.
Example Usage
Suppose you want to pass the execution date to a task. You can use the {{ ds }} context variable directly.