Which statement best describes the structure of a DAG in Apache Airflow?
Think about what 'acyclic' means in the context of graph structures.
A DAG (Directed Acyclic Graph) means tasks are connected with directed edges and no cycles exist, so the workflow has a clear direction and no loops.
Given the following Airflow DAG snippet, what is the order of task execution?
from airflow import DAG from airflow.operators.dummy import DummyOperator from datetime import datetime dag = DAG('example_dag', start_date=datetime(2024, 1, 1)) t1 = DummyOperator(task_id='task1', dag=dag) t2 = DummyOperator(task_id='task2', dag=dag) t3 = DummyOperator(task_id='task3', dag=dag) t1 >> [t2, t3]
Look at the dependency operator '>>' and what it means for task order.
The '>>' operator means task1 must finish before task2 and task3 start. Tasks 2 and 3 can run at the same time after task1.
Which of the following DAG definitions will cause an error due to cycle detection in Airflow?
from airflow import DAG from airflow.operators.dummy import DummyOperator from datetime import datetime dag = DAG('cycle_dag', start_date=datetime(2024, 1, 1)) t1 = DummyOperator(task_id='task1', dag=dag) t2 = DummyOperator(task_id='task2', dag=dag) t3 = DummyOperator(task_id='task3', dag=dag) # Dependencies to check
Check if any task depends on itself directly or indirectly.
Option D creates a cycle because task1 depends on task3, which depends back on task1, causing a loop. Airflow does not allow cycles in DAGs.
You have a DAG where task3 runs before task2, but your code specifies t1 >> t2 >> t3. What is the most likely cause?
Think about how Airflow reads DAG files and updates task dependencies.
If the DAG file is not saved after adding dependencies, Airflow will run the last saved version which may not have the correct order, causing tasks to run out of sequence.
Consider a DAG with tasks: t1, t2, t3, t4, t5. The dependencies are:
- t1 >> t2
- t1 >> t3
- t2 >> t4
- t3 >> t4
- t4 >> t5
If task t3 fails and depends_on_past=False, how many tasks will run successfully in the next DAG run?
Consider which tasks depend on the failed task and how failure affects downstream tasks.
Task t3 fails, so t4 cannot run because it depends on both t2 and t3. t5 depends on t4, so it also won't run. Only t1 and t2 run successfully.