Add multiple_outputs
option to PythonOperator
#37284
Labels
area:core
area:core-operators
Operators, Sensors and hooks within Core Airflow
kind:feature
Feature Requests
Description
Add a new optional field
return_multiple
toPythonOperator
, which automatically splits returned dicts into separate XComs.Use case/motivation
Currently, the task-flow decorator
@task
accepts a boolean argumentmultiple_outputs
, which automatically splits any returned dictionary of values into separate xcom values. Using this feature, the following code can be compacted fromto
This abstracts away the airflow-ism of task instances and still enables using each part of the returned value separately via e.g.
split_csv.output["rows_csv"]
.This feature is not available for any other operator, though I feel like it would be very useful. I'm open to implementing this by applying the existing code from
airflow.decorators.base.DecoratedOperator
toPythonOperator
, sinceBaseOperator
doesn't implement any handling of returned values.Please let me know what you think about this change. 🙂
Related issues
No response
Are you willing to submit a PR?
Code of Conduct
The text was updated successfully, but these errors were encountered: