Xcom | Airflow

load_user = PostgresOperator( task_id='load_user', postgres_conn_id='my_postgres', sql="INSERT INTO users (name) VALUES (' ti.xcom_pull(task_ids='extract_user') ');", # The Jinja template pulls the value from the previous task at runtime )

While automatic return_value pushing is convenient, explicit keys ( ti.xcom_push(key='status') ) can make your DAGs easier to debug in the UI, as you can search for specific keys rather than generic return_value entries. airflow xcom

Use the syntax.

@staticmethod def serialize(value): # 1. Convert value to string/bytes data = json.dumps(value).encode('utf-8') load_user = PostgresOperator( task_id='load_user'

@task def extract(): return "user_id": 42, "name": "Alice" # Auto-pushed as 'return_value' "name": "Alice" # Auto-pushed as 'return_value'