Challenge - 5 Problems
TaskFlow XCom Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Airflow TaskFlow function?
Given the following Airflow DAG task using TaskFlow API, what will be the output when the task runs successfully?
Apache Airflow
from airflow.decorators import task @task def multiply_by_two(x: int) -> int: return x * 2 result = multiply_by_two(5) print(result)
Attempts:
2 left
💡 Hint
Remember that TaskFlow API returns a special object representing the task output, not the raw value.
✗ Incorrect
In Airflow's TaskFlow API, calling a decorated task function returns an XComArg object, which represents the future result of the task. The actual value is pushed to XCom only after the task runs.
🧠 Conceptual
intermediate2:00remaining
Which statement best describes XCom behavior in TaskFlow API?
Select the correct statement about how XComs are handled when using Airflow's TaskFlow API.
Attempts:
2 left
💡 Hint
Think about how TaskFlow API simplifies passing data between tasks.
✗ Incorrect
TaskFlow API automatically handles pushing the return value of a decorated task to XCom, so you don't need to manually push or pull values.
❓ Troubleshoot
advanced2:00remaining
Why does this TaskFlow task fail to push the expected XCom value?
Consider this task code snippet:
from airflow.decorators import task
@task
def add_numbers(a, b):
sum = a + b
What is the reason the XCom value is None after task execution?
Attempts:
2 left
💡 Hint
Check if the function returns a value to be pushed to XCom.
✗ Incorrect
In TaskFlow API, only the return value of the decorated function is pushed to XCom. Without a return statement, the XCom value is None.
🔀 Workflow
advanced2:00remaining
What is the correct way to pass data between two TaskFlow tasks?
Given two tasks defined with TaskFlow API:
@task
def task_a():
return 42
@task
def task_b(x):
return x + 1
How do you correctly set up the DAG to pass the output of task_a to task_b?
Attempts:
2 left
💡 Hint
Remember that calling a task returns an XComArg that can be passed as argument to another task.
✗ Incorrect
Calling task_a() returns an XComArg object representing its output, which can be passed directly as argument to task_b().
✅ Best Practice
expert3:00remaining
Which approach best improves XCom data handling in TaskFlow API for large data?
You have a TaskFlow task that returns a large dictionary. Which method is best to avoid performance issues with XCom?
Attempts:
2 left
💡 Hint
Think about how to keep XCom lightweight and efficient.
✗ Incorrect
XCom is designed for small messages. For large data, best practice is to store it externally and pass only a reference via XCom to avoid performance degradation.