Skip to main content

Essential Apache Airflow Interview Questions & Answers (Explained Through Real-World Stories) – Part 2

6. What is the Airflow UI used for?

Imagine you've scheduled hundreds of workflows every day.

How do you know:

  • Which DAG is currently running?
  • Which task failed?
  • How long did a task take?
  • Why did it fail?

Instead of checking log files manually, Apache Airflow provides a powerful Web UI.

The Airflow UI helps you monitor, troubleshoot, and manage your workflows from a web browser.

Some useful views include:

ViewPurpose
DAGs ViewDisplays all available DAGs
Graph ViewShows task dependencies visually
Grid ViewDisplays task status across DAG runs
Code ViewShows the DAG source code
LogsDisplays execution logs for each task

Real-World Example

Suppose your ETL pipeline looks like this:

Extract Data

Transform Data

Load Warehouse

Generate Report

If Transform Data fails, the UI highlights the failed task, allowing you to inspect its logs without searching through server files.


7. How do you create your first DAG in Apache Airflow?

A DAG is simply a Python file that defines your workflow.

Example:

from airflow import DAG
from airflow.operators.empty import EmptyOperator
from datetime import datetime

with DAG(
dag_id="first_dag",
start_date=datetime(2025, 1, 1),
schedule="@daily",
catchup=False
) as dag:

start = EmptyOperator(task_id="start")

Explanation

  • dag_id uniquely identifies the DAG.
  • start_date tells Airflow when scheduling begins.
  • schedule defines how often the DAG runs.
  • catchup=False prevents Airflow from running historical schedules.

Once saved inside the dags/ folder, Airflow automatically discovers the DAG.


8. What are Operators in Apache Airflow?

Operators define what each task should do.

Think of an Operator as a worker assigned a specific responsibility.

For example, in an ETL workflow:

Download File

Run Python Script

Execute SQL Query

Send Email

Each step is performed by a different Operator.

Some commonly used Operators are:

OperatorPurpose
PythonOperatorExecutes Python functions
BashOperatorRuns shell commands
EmptyOperatorPlaceholder task
EmailOperatorSends emails
HttpOperatorCalls REST APIs

Example

from airflow.operators.bash import BashOperator

task = BashOperator(
task_id="list_files",
bash_command="ls -l"
)

This task executes the Linux command ls -l.


9. How do you define task dependencies in Airflow?

Many workflows require tasks to execute in a specific order.

For example:

Receive File

Validate Data

Transform Data

Load Database

You don't want Load Database to start before Validate Data finishes.

Airflow lets you define dependencies using the >> and << operators.

Example

extract >> transform >> load

This means:

  • extract runs first.
  • transform starts only after extract succeeds.
  • load runs after transform.

You can also define parallel tasks.

start >> [task1, task2, task3]

Here, all three tasks run simultaneously after start completes.


10. How does scheduling work in Apache Airflow?

Scheduling determines when a DAG should execute.

Airflow supports:

  • Fixed schedules
  • Cron expressions
  • Presets
  • Manual triggers
  • Dataset-based scheduling (Airflow 2.4+)

Common Schedule Examples

ScheduleMeaning
@onceRun only once
@hourlyEvery hour
@dailyOnce every day
@weeklyEvery week
@monthlyEvery month

You can also use Cron expressions.

Example:

schedule="0 8 * * *"

This runs the DAG every day at 8:00 AM.

Another example:

schedule="*/15 * * * *"

This executes the DAG every 15 minutes.

Real-World Example

A retail company refreshes sales dashboards every morning at 6 AM.

Instead of manually starting the workflow every day, Airflow automatically triggers the DAG using a scheduled interval.


Summary

QuestionTopic
6Airflow UI
7Creating Your First DAG
8Operators
9Task Dependencies
10Scheduling & Cron Expressions

Interview Tip

A common interview question is:

"What is the difference between scheduling a DAG and manually triggering a DAG?"

A simple answer:

  • Scheduling runs the DAG automatically according to a predefined schedule.
  • Manual triggering starts the DAG on demand, regardless of its schedule.

Both methods create a DAG run, but the trigger mechanism is different.