default_args = { 'owner': 'airflow', 'depends_on_past': False, 'start_date': datetime(2023, 3, 20), 'retries': 1, 'retry_delay': timedelta(minutes=5), }
dag = DAG( 'xcom_example', default_args=default_args, schedule_interval=timedelta(days=1), )
task2 = BashOperator( task_id='task2', bash_command='echo {{ task_instance.xcom_pull("greeting") }}', dag=dag, )
In Airflow, XCom is implemented as a key-value store that's accessible to all tasks in a DAG. When a task wants to share data with other tasks, it can use the xcom_push method to store a value in XCom. Other tasks can then use the xcom_pull method to retrieve that value.
Here's a simple example of how XCom works:
task1 = BashOperator( task_id='task1', bash_command='echo "Hello, World!"', xcom_push_key='greeting', dag=dag, )
default_args = { 'owner': 'airflow', 'depends_on_past': False, 'start_date': datetime(2023, 3, 20), 'retries': 1, 'retry_delay': timedelta(minutes=5), }
dag = DAG( 'xcom_example', default_args=default_args, schedule_interval=timedelta(days=1), ) airflow xcom exclusive
task2 = BashOperator( task_id='task2', bash_command='echo {{ task_instance.xcom_pull("greeting") }}', dag=dag, ) default_args = { 'owner': 'airflow'
In Airflow, XCom is implemented as a key-value store that's accessible to all tasks in a DAG. When a task wants to share data with other tasks, it can use the xcom_push method to store a value in XCom. Other tasks can then use the xcom_pull method to retrieve that value. } dag = DAG( 'xcom_example'
Here's a simple example of how XCom works:
task1 = BashOperator( task_id='task1', bash_command='echo "Hello, World!"', xcom_push_key='greeting', dag=dag, )