Search code examples
airflow

Make downstream task dependent on Branch Operator, but execute anyway if branch condition not satisfied


I am trying to execute the following airflow dag:

start >> BranchDayOfWeekOperator >> TaskA >> TaskB >> end

I want TaskB to be dependent on TaskA when the branching condition is satisfied. However, when it is not satisfied, execute TaskB anyways.

start >> TaskB >> end

Is this possible?


Solution

  • Yes, this is possible. Simply change the trigger_rule for TaskB to none_failed. Then, even if upstream tasks are skipped, TaskB will run as long as none of the tasks have explicitly failed.