Airflow Xcoms !free! File
– Possible but painful. You need to specify dag_id and run_id , and the DB overhead grows quickly.
bash_task = BashOperator( task_id='bash_task', bash_command='echo "Received ID: ti.xcom_pull(task_ids="extract_task") "', ) airflow xcoms
# Task 2: pull data from XCom task_2 = BashOperator( task_id='task_2', bash_command='echo task_instance.xcom_pull("greeting") ', dag=dag, ) – Possible but painful
Tip: For passing large data, use external storage like S3, GCS, or an SQL table, and pass only the file path/reference through XCom. How to Use XComs: A Practical Guide There are two primary ways to work with XComs in Airflow. 1. The Automatic Way (Return Values) How to Use XComs: A Practical Guide There
When a task "pushes" an XCom, it stores a value associated with a key. Any other task running after it can "pull" that value using the same key.
with DAG('xcom_example', start_date=datetime(2023, 1, 1), schedule_interval=None) as dag: