BranchDayOfWeekOperator

Use the BranchDayOfWeekOperator to branch your workflow based on week day value.

airflow/example_dags/example_branch_day_of_week_operator.py[source]

empty_task_1 = EmptyOperator(task_id='branch_true')
empty_task_2 = EmptyOperator(task_id='branch_false')

branch = BranchDayOfWeekOperator(
    task_id="make_choice",
    follow_task_ids_if_true="branch_true",
    follow_task_ids_if_false="branch_false",
    week_day="Monday",
)

# Run empty_task_1 if branch executes on Monday
branch >> [empty_task_1, empty_task_2]

Was this entry helpful?