0
0
Apache Airflowdevops~5 mins

XCom with return values in Apache Airflow - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an XCom in Apache Airflow?
An XCom (short for cross-communication) is a way for tasks in Airflow to exchange small pieces of data or messages during a workflow run.
Click to reveal answer
beginner
How do you return a value from a PythonOperator task to be used by another task?
You return the value from the Python function used in the PythonOperator. Airflow automatically pushes this return value as an XCom.
Click to reveal answer
intermediate
How can a downstream task pull an XCom value returned by an upstream task?
Use the task instance's xcom_pull method with the task_id of the upstream task to get the returned value.
Click to reveal answer
intermediate
What is the default key used when pushing XComs with return values?
The default key is 'return_value' when a task returns a value that Airflow pushes as an XCom.
Click to reveal answer
beginner
Why should XComs be used only for small data?
Because XComs store data in the Airflow metadata database, large data can slow down the system and cause performance issues.
Click to reveal answer
What happens when a PythonOperator's Python function returns a value?
AThe value is saved to a file.
BThe value is ignored unless manually pushed.
CThe value is automatically pushed as an XCom with key 'return_value'.
DThe task fails.
Which method is used to retrieve an XCom value in a task?
Axcom_push()
Bxcom_pull()
Cget_xcom()
Dfetch_xcom()
What is the recommended size of data to pass via XComs?
ASmall pieces of data like strings or numbers
BLarge files like images or videos
CEntire databases
DFull application logs
If you want to pass multiple values via XCom, what should you do?
AReturn a dictionary or list from the Python function
BReturn multiple values separately
CUse multiple PythonOperators
DXComs do not support multiple values
Which Airflow component stores XCom data?
AScheduler
BWorker logs
CExecutor
DMetadata database
Explain how to pass data from one task to another using XCom return values in Airflow.
Think about how Python functions return values and how Airflow handles them.
You got /3 concepts.
    Describe best practices and limitations when using XComs for passing data between tasks.
    Consider performance and storage when using XComs.
    You got /4 concepts.