Recall & Review
beginner
What is an XCom in Airflow?
An XCom (short for cross-communication) is a way for tasks in Airflow to share small pieces of data or messages between each other during a workflow run.
Click to reveal answer
beginner
How do you push an XCom value in a PythonOperator task?
You can push an XCom by returning a value from the Python function used in the PythonOperator. Airflow automatically pushes the return value as an XCom.
Click to reveal answer
intermediate
How can you pull an XCom value from another task?
Use the task instance's xcom_pull method with the task_id of the task that pushed the value. For example: ti.xcom_pull(task_ids='task_id').
Click to reveal answer
intermediate
What parameters can you use with xcom_pull to get specific data?
You can specify task_ids, key (default is 'return_value'), and include_prior_dates to control which XCom value you want to pull.
Click to reveal answer
advanced
Can you push an XCom manually without returning a value?
Yes, by using the xcom_push method inside a task's context, you can push any key-value pair as an XCom without returning it.
Click to reveal answer
What does Airflow automatically do when a PythonOperator's function returns a value?
✗ Incorrect
Airflow automatically pushes the return value of a PythonOperator's function as an XCom for other tasks to use.
Which method is used to retrieve an XCom value from another task?
✗ Incorrect
The xcom_pull method is used to get XCom values from other tasks.
What is the default key used when pulling an XCom value if no key is specified?
✗ Incorrect
The default key for XCom values is 'return_value' when no key is specified.
How can you push an XCom value manually inside a task?
✗ Incorrect
You can manually push an XCom using ti.xcom_push with a key and value.
Which of the following is NOT a valid parameter for xcom_pull?
✗ Incorrect
'push_value' is not a parameter for xcom_pull; the others are valid.
Explain how to share data between two tasks in Airflow using XComs.
Think about how one task sends and another receives small data pieces.
You got /3 concepts.
Describe the difference between pushing XComs by returning a value and manually pushing with xcom_push.
Consider when you want to send multiple or named pieces of data.
You got /3 concepts.