0
0
Apache Airflowdevops~20 mins

TaskFlow API for cleaner XCom in Apache Airflow - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
TaskFlow XCom Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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)
AXComArg object
B10
CNone
DTypeError
Attempts:
2 left
💡 Hint
Remember that TaskFlow API returns a special object representing the task output, not the raw value.
🧠 Conceptual
intermediate
2: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.
ATaskFlow API disables XComs by default to improve performance.
BYou must manually push XCom values using task_instance.xcom_push() inside the task.
CTaskFlow API automatically serializes and pushes return values to XCom without extra code.
DXComs are only available if you use PythonOperator, not TaskFlow API.
Attempts:
2 left
💡 Hint
Think about how TaskFlow API simplifies passing data between tasks.
Troubleshoot
advanced
2: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?
AThe function does not return the sum, so nothing is pushed to XCom.
BThe @task decorator requires explicit xcom_push calls inside the function.
CThe variables a and b are not typed, causing serialization failure.
DAirflow disables XCom for functions with more than one argument.
Attempts:
2 left
💡 Hint
Check if the function returns a value to be pushed to XCom.
🔀 Workflow
advanced
2: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?
A
result = task_a()
task_b()  # no argument
B
task_a()
task_b(task_a())  # call twice
Cfinal = task_b(task_a) # pass function, not result
D
result = task_a()
final = task_b(result)
Attempts:
2 left
💡 Hint
Remember that calling a task returns an XComArg that can be passed as argument to another task.
Best Practice
expert
3: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?
ASerialize the dictionary as a JSON string and return it directly from the task.
BStore the large data in external storage (e.g., S3) and push only the reference (path) via XCom.
CSplit the dictionary into smaller chunks and return multiple tasks each pushing part of data.
DIncrease Airflow's XCom max size limit to accommodate the large dictionary.
Attempts:
2 left
💡 Hint
Think about how to keep XCom lightweight and efficient.