0
0
Apache Airflowdevops~20 mins

Task dependencies (>> and << operators) in Apache Airflow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Airflow Dependency Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding the effect of >> operator in Airflow DAGs

Given the following Airflow task dependencies:

task1 >> task2 >> task3

Which statement best describes the execution order of these tasks?

Atask1 runs first, then task2, then task3
Btask3 runs first, then task2, then task1
CAll tasks run in parallel without order
Dtask2 runs first, then task1, then task3
Attempts:
2 left
💡 Hint

The >> operator sets the order from left to right.

💻 Command Output
intermediate
1:30remaining
Output of task dependencies using << operator

Consider the following Airflow task dependencies:

task3 << task2 << task1

What is the correct execution order of the tasks?

Atask2 runs first, then task3, then task1
Btask3 runs first, then task2, then task1
Ctask1 runs first, then task2, then task3
DAll tasks run simultaneously
Attempts:
2 left
💡 Hint

The << operator sets upstream dependencies.

🔀 Workflow
advanced
2:00remaining
Creating a diamond-shaped task dependency graph

You want to create a DAG where task1 runs first, then task2 and task3 run in parallel, and finally task4 runs after both task2 and task3 complete.

Which code snippet correctly sets these dependencies using >> and/or << operators?

A[task2, task3] >> task1 >> task4
Btask1 << [task2, task3] << task4
Ctask4 >> [task2, task3] >> task1
Dtask1 >> [task2, task3] >> task4
Attempts:
2 left
💡 Hint

Use >> to set downstream dependencies and list to set parallel tasks.

Troubleshoot
advanced
1:30remaining
Identifying incorrect task dependency causing cyclic error

Given the following dependencies:

task1 >> task2
 task2 >> task3
 task3 >> task1

What error will Airflow raise when parsing this DAG?

AAirflowDagCycleException due to cyclic dependency
BTaskNotFound error because task3 is missing
CNo error, DAG runs successfully
DSyntaxError due to invalid operator usage
Attempts:
2 left
💡 Hint

Check if the dependencies form a loop.

Best Practice
expert
2:30remaining
Choosing the best way to set multiple dependencies for clarity

You have tasks start, middle1, middle2, and end. You want start to run first, then middle1 and middle2 in parallel, and finally end after both middles finish.

Which of the following is the clearest and most maintainable way to set these dependencies using >> and/or << operators?

Astart >> [middle1, middle2] >> end
B
start &gt;&gt; middle1
start &gt;&gt; middle2
middle1 &gt;&gt; end
middle2 &gt;&gt; end
C[start, middle1] >> middle2 >> end
Dend << middle1 << middle2 << start
Attempts:
2 left
💡 Hint

Consider readability and explicitness for future maintenance.