Use case of dummy operator

dummy_operator is used in BranchPythonOperator where we decide next task based on some condition.

For example:

                  -> task C->task D

 task A -> task B                      -> task F
                   ->  task E(Dummy)

So let's suppose we have some condition in task B which decides whether to follow [task C->task D] or task E(Dummy) to reach task F.

Since we cannot leave else condition empty we have to put dummy operator which does nothing just skip or bypass.


Operator that does literally nothing. It can be used to group tasks in a DAG.

https://airflow.apache.org/_api/airflow/operators/dummy_operator/index.html

as far as I know, at least to two case:

  • test purpose. in dags, the dummy operation just between upstream and downstream, later, you can replace the true operator.
  • Workflow purpose: BranchPythonOperator work with DummyOperator. If you want to skip some tasks, keep in mind that you can’t have an empty path, if so make a dummy task. https://airflow.apache.org/concepts.html#workflows

Another use case: I've implemented a framework that returns an Operator. In most cases this is a PostgresOperator but under some user-specified configuration there's no SQL to run but the caller still expects an Operator so I return a DummyOperator rather than a PostgresOperator with trivial SQL like "select 1;".