Airflow Xcom Example //top\\ -
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.
One of the most common questions when building DAGs is: 👉 "How do I pass data from one task to another?"
# Push context['ti'].xcom_push(key='user_id', value=123) user = context['ti'].xcom_pull(task_ids='task_a', key='user_id') 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. 🧠
Go to Task Instance → XCom tab → See key-value pairs. XComs allow tasks to exchange small pieces of data (e
push = PythonOperator(task_id='push_task', python_callable=push_func) pull = PythonOperator(task_id='pull_task', python_callable=pull_func)
process = PythonOperator( task_id='process_order_task', python_callable=process_order ) value=123) user = context['ti'].xcom_pull(task_ids='task_a'
extract >> process