One of the most common questions when building DAGs is: 👉 "How do I pass data from one task to another?"
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}") airflow xcom example
The answer:
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. 🧠 One of the most common questions when building
3/4 ⚠️ Warning: XCom is NOT for large data (no CSVs, no models). Keep it under 48KB. Use S3/GCS for big files. airflow xcom example
with DAG('xcom_example', start_date=datetime(2024, 1, 1), schedule_interval=None) as dag:
Use return as a shortcut – return value auto-pushes to return_value key.