0
0
Apache Airflowdevops~10 mins

Execution date vs logical date in Apache Airflow - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print the logical date of an Airflow task instance.

Apache Airflow
print(ti.[1])
Drag options to blanks, or click blank then click option'
Aexecution_date
Bstart_date
Clogical_date
Drun_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using execution_date instead of logical_date
Confusing start_date with logical_date
2fill in blank
medium

Complete the code to get the execution date from the context dictionary in an Airflow operator.

Apache Airflow
exec_date = context.get('[1]')
Drag options to blanks, or click blank then click option'
Aexecution_date
Blogical_date
Cstart_date
Drun_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using logical_date key which is not in context
Using start_date which is a DAG attribute
3fill in blank
hard

Fix the error in the code to correctly compare execution date and logical date.

Apache Airflow
if ti.execution_date == ti.[1]:
    print('Dates match')
Drag options to blanks, or click blank then click option'
Alogical_date
Brun_date
Cstart_date
Dschedule_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using run_date which is not a valid attribute
Using start_date which is a DAG property, not task instance
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps logical dates to execution dates for task instances.

Apache Airflow
{ti.[1]: ti.[2] for ti in task_instances}
Drag options to blanks, or click blank then click option'
Alogical_date
Bexecution_date
Cstart_date
Drun_date
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping logical_date and execution_date
Using start_date or run_date which are not task instance attributes
5fill in blank
hard

Fill all three blanks to filter task instances where execution date is after logical date and create a dictionary with logical date keys and execution date values.

Apache Airflow
{ti.[1]: ti.[2] for ti in task_instances if ti.[3] > ti.[1]
Drag options to blanks, or click blank then click option'
Alogical_date
Bexecution_date
Cstart_date
Drun_date
Attempts:
3 left
💡 Hint
Common Mistakes
Using start_date or run_date which are not task instance attributes
Mixing up the comparison order