BigData / Apache Airflow Interview Questions
What is a DAG in Apache Airflow?
A DAG (Directed Acyclic Graph) is the core concept in Airflow. It is a collection of tasks organized with dependencies and relationships that define how they should run. The "directed" part means each edge has a direction (from one task to another). "Acyclic" means there are no loops - you cannot create a cycle where task A depends on task B which depends on task A.
A simple DAG example:
from airflow import DAG
from airflow.operators.python import PythonOperator
from datetime import datetime
with DAG('my_dag', start_date=datetime(2024, 1, 1), schedule='@daily') as dag:
t1 = PythonOperator(task_id='task_1', python_callable=lambda: print('Hello'))
t2 = PythonOperator(task_id='task_2', python_callable=lambda: print('World'))
t1 » t2 # t2 runs after t1
More Related questions...