Recall & Review
beginner
What is the purpose of the BranchPythonOperator in Airflow?
BranchPythonOperator lets you choose which task to run next based on a condition in your Python code. It helps create decision points in your workflow.
Click to reveal answer
beginner
How does BranchPythonOperator decide the next task to execute?
It runs a Python function that returns the task ID(s) of the next task(s) to run. Only those tasks will be executed next.
Click to reveal answer
intermediate
Can BranchPythonOperator return multiple task IDs? What happens then?
Yes, it can return a list of task IDs. Airflow will run all those tasks in parallel next.
Click to reveal answer
intermediate
What happens to tasks that are not chosen by BranchPythonOperator?
Tasks not returned by the BranchPythonOperator are skipped and will not run in that workflow run.
Click to reveal answer
beginner
Write a simple example of a Python function used with BranchPythonOperator.
def choose_branch():
condition = True # Define your condition here
if condition:
return 'task_a'
else:
return 'task_b'
This function returns the next task ID based on a condition.
Click to reveal answer
What does BranchPythonOperator return to decide the next task?
✗ Incorrect
BranchPythonOperator runs a Python function that returns the task ID or list of task IDs to run next.
If BranchPythonOperator returns multiple task IDs, what happens?
✗ Incorrect
All tasks returned by BranchPythonOperator run in parallel next.
What happens to tasks not returned by BranchPythonOperator?
✗ Incorrect
Tasks not chosen by BranchPythonOperator are skipped in that run.
Which Airflow operator is used to create decision points in workflows?
✗ Incorrect
BranchPythonOperator is designed to create branches or decision points.
What type of function must you provide to BranchPythonOperator?
✗ Incorrect
The function must return the next task ID(s) to run.
Explain how BranchPythonOperator controls the flow of tasks in an Airflow DAG.
Think about how you choose a path in a choose-your-own-adventure story.
You got /4 concepts.
Describe a simple use case where BranchPythonOperator would be helpful in a workflow.
Imagine deciding what to cook based on what ingredients you have.
You got /4 concepts.