0
0
Apache Airflowdevops~20 mins

Pushing and pulling XCom values in Apache Airflow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
XCom Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of pulling an XCom value?
Given a task pushes an XCom value with key 'result' and value 42, what will be the output of pulling this XCom in another task?
Apache Airflow
value = ti.xcom_pull(task_ids='push_task', key='result')
print(value)
ANone
B'' (empty string)
CKeyError
D42
Attempts:
2 left
💡 Hint
Remember that xcom_pull returns the value pushed with the matching key and task_id.
🧠 Conceptual
intermediate
1:00remaining
Which method is used to push an XCom value in Airflow?
You want to share data from one task to another using XComs. Which method should you use inside a task to push a value?
Ati.xcom_push(key='my_key', value='data')
Bpush_xcom(ti, key='my_key', value='data')
Cxcom_push(key='my_key', value='data')
Dti.push_xcom(key='my_key', value='data')
Attempts:
2 left
💡 Hint
The method is called on the task instance object (ti).
Troubleshoot
advanced
2:00remaining
Why does xcom_pull return None unexpectedly?
You have two tasks: 'push_task' pushes an XCom with key 'data'. 'pull_task' tries to pull it but gets None. What is a likely cause?
A'pull_task' runs before 'push_task' completes
BThe key used in xcom_pull is misspelled
CAll of the above
D'push_task' did not call ti.xcom_push
Attempts:
2 left
💡 Hint
Consider timing, spelling, and whether the push actually happened.
🔀 Workflow
advanced
2:30remaining
Order of operations for pushing and pulling XComs
Arrange the steps in the correct order to share data between two Airflow tasks using XComs.
A1,3,4,2
B3,1,4,2
C1,4,3,2
D3,4,1,2
Attempts:
2 left
💡 Hint
Pushing happens during Task A execution, which must complete before Task B runs and pulls.
Best Practice
expert
3:00remaining
What is the recommended way to avoid XCom data size issues?
XComs have size limits. Which approach is best to handle large data sharing between tasks?
ACompress data and push compressed bytes in XCom
BStore large data in external storage and push only a reference via XCom
CSplit large data into many small XCom pushes
DIncrease Airflow database size limits to accommodate large XComs
Attempts:
2 left
💡 Hint
Think about scalability and Airflow best practices.