Airflow — Xcom Example

process = PythonOperator( task_id='process_order_task', python_callable=process_order )

3/4 ⚠️ Warning: XCom is NOT for large data (no CSVs, no models). Keep it under 48KB. Use S3/GCS for big files.

Use return as a shortcut – return value auto-pushes to return_value key. airflow xcom example

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}")

Title: Mastering Data Sharing in Airflow: XComs Explained with a Real Example process = PythonOperator( task_id='process_order_task'

def auto_push(): return "auto_xcom" # automatically in XCom

with DAG('xcom_example', start_date=datetime(2024, 1, 1), schedule_interval=None) as dag: schedule_interval=None) as dag: The answer:

The answer: