Challenge - 5 Problems
Airflow DAG Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of a simple Airflow DAG run
Given this Airflow DAG code, what will be the output when the task runs successfully?
Apache Airflow
from airflow import DAG from airflow.operators.python import PythonOperator from datetime import datetime def greet(): print('Hello from Airflow!') default_args = { 'start_date': datetime(2024, 1, 1) } dag = DAG('greet_dag', default_args=default_args, schedule_interval='@daily') task = PythonOperator( task_id='greet_task', python_callable=greet, dag=dag )
Attempts:
2 left
💡 Hint
The PythonOperator runs the greet function which prints a message.
✗ Incorrect
The greet function prints 'Hello from Airflow!' when the task runs successfully.
🧠 Conceptual
intermediate1:30remaining
Understanding DAG schedule_interval
What does the schedule_interval='@hourly' mean in an Airflow DAG?
Attempts:
2 left
💡 Hint
Think about how often '@hourly' triggers the DAG.
✗ Incorrect
'@hourly' is a preset that schedules the DAG to run once every hour.
❓ Configuration
advanced2:00remaining
Correct DAG default_args configuration
Which option correctly sets the default_args for an Airflow DAG with a start date of January 1, 2024, and retries set to 3?
Attempts:
2 left
💡 Hint
Check the types of values and syntax for dictionary keys and values.
✗ Incorrect
Option A uses correct Python dictionary syntax with proper types for start_date and retries.
❓ Troubleshoot
advanced2:00remaining
Identifying error in DAG task definition
What error will occur with this task definition in an Airflow DAG?
from airflow.operators.python import PythonOperator
task = PythonOperator(
task_id='task1'
python_callable=lambda: print('Hi')
dag=dag
)
Attempts:
2 left
💡 Hint
Look carefully at the commas separating arguments in the function call.
✗ Incorrect
The task definition is missing commas between arguments, causing a SyntaxError.
🔀 Workflow
expert3:00remaining
Order of steps to create and run a basic Airflow DAG
What is the correct order of steps to create and run a basic Airflow DAG?
Attempts:
2 left
💡 Hint
Think about writing code first, then placing it, then starting services, then running.
✗ Incorrect
You first write the DAG file, then place it in the DAGs folder, start Airflow services, then trigger the DAG.