extract = PythonOperator( task_id='extract_order_task', python_callable=extract_order )
XComs allow tasks to exchange small pieces of data (e.g., IDs, filenames, metadata). Think of them as a shared key-value store across your DAG run.
from airflow.operators.python import PythonOperator def push_func(ti): ti.xcom_push(key='result', value='hello_xcom') airflow xcom example
1/4 Ever needed to pass a value from one Airflow task to another? → Use (Cross-Communication). Think of it as a mini shared dictionary for your DAG run. 🧠
The answer:
extract >> process
def process_order(**context): # Pull from XCom order_id = context['task_instance'].xcom_pull( task_ids='extract_order_task', key='order_id' ) print(f"Processing order: {order_id}") extract = PythonOperator( task_id='extract_order_task'
One of the most common questions when building DAGs is: 👉 "How do I pass data from one task to another?"