The Dummy Operator
The DummyOperator is a simple operator that does nothing. It's useful for creating branches in your DAGs or for marking the start and end of your workflows without performing any actual tasks. This operator is deprecated and will be removed in a future version of Airflow. Please use the EmptyOperator instead.
Use Cases
- Creating placeholder tasks for future implementation.
- Defining the start and end points of a DAG for organizational purposes.
- Simplifying complex branching logic where intermediate steps don't require execution.
Operator Details
Operator Class
airflow.operators.dummy_operator.DummyOperator
Type
Utility Operator
Status
Deprecated
Alternative
EmptyOperator
Parameters
The DummyOperator inherits from BaseOperator and does not have any specific parameters beyond those inherited. The most commonly used inherited parameters are:
| Parameter | Type | Description | Required | Default |
|---|---|---|---|---|
task_id |
str |
The unique identifier for the task within the DAG. | Yes | None |
dag |
DAG |
The DAG to associate this task with. | No | None |
trigger_rule |
str |
Defines the conditions under which a task will be scheduled. | No | "all_success" |
queue |
str |
The name of the queue this task should be executed in. | No | None |
pool |
str |
The name of the pool this task should acquire resources from. | No | "default_pool" |
Example Usage
Here's a simple example of how to use the DummyOperator to create a start and end task in a DAG.
from __future__ import annotations
import pendulum
from airflow.models.dag import DAG
from airflow.operators.dummy import DummyOperator # Note: Use EmptyOperator in newer versions
with DAG(
dag_id="dummy_operator_example",
start_date=pendulum.datetime(2023, 1, 1, tz="UTC"),
catchup=False,
tags=["example", "dummy", "deprecated"],
) as dag:
start = DummyOperator(task_id="start_task")
process_data = DummyOperator(task_id="process_data_task")
end = DummyOperator(task_id="end_task")
start >> process_data >> end
Important Note on Deprecation
The DummyOperator has been deprecated. In modern Airflow versions (2.2+), you should use the EmptyOperator which serves the same purpose without the baggage of being named "dummy". The EmptyOperator is the recommended way to create placeholder tasks.
To use the EmptyOperator, simply import it from airflow.operators.empty and use it in the same way you would have used DummyOperator:
from airflow.operators.empty import EmptyOperator
# ... inside your DAG definition ...
start = EmptyOperator(task_id="start_task")
end = EmptyOperator(task_id="end_task")