Airflow - Xcom Exclusive
This article dives deep into XCom exclusive mode, comparing it with the standard model, walking through practical examples, and revealing advanced patterns to level up your Airflow engineering.
# Pushing XCom (implicitly via return) def push_task(**context): return "some_value" airflow xcom exclusive
Airflow 2.7 introduced an ( BaseXCom ). With it, you can define: This article dives deep into XCom exclusive mode,
task1 = BashOperator( task_id='task1', bash_command='echo "Hello, World!"', xcom_push_key='greeting', dag=dag, ) It is designed for passing small pieces of
Simple design:
This is the cardinal rule of XCom. It is designed for passing small pieces of state, such as file paths, status strings, or row counts. Avoid passing large DataFrames, entire query results, or large JSON payloads. If you need to pass large datasets, consider having your tasks write the data to a shared location (like your data lake) and then just pass the file path via XCom.
print(f"Loading data from file_path with count records")