Airflow Xcom Example Info
process = PythonOperator( task_id='process_order_task', python_callable=process_order )
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. 🧠 airflow xcom example
# Push context['ti'].xcom_push(key='user_id', value=123) user = context['ti'].xcom_pull(task_ids='task_a', key='user_id') process = PythonOperator( task_id='process_order_task'
Use return as a shortcut – return value auto-pushes to return_value key. value=123) user = context['ti'].xcom_pull(task_ids='task_a'
extract >> process
Go to Task Instance → XCom tab → See key-value pairs.
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.