This change enables Jinja templating for ProduceToTopicOperator. It's useful when the producer function needs access to execution context, e.g. date interval, or when it depends on the upstream result, e.g. XCom variable. Otherwise, you have to write a custom PythonOperator and use the Hook/Producer directly.
Example 1 - dynamically route messages to a topic based on upstream status:
This change enables Jinja templating for
ProduceToTopicOperator
. It's useful when the producer function needs access to execution context, e.g. date interval, or when it depends on the upstream result, e.g. XCom variable. Otherwise, you have to write a customPythonOperator
and use the Hook/Producer directly.Example 1 - dynamically route messages to a topic based on upstream status:
Example 2 - access the context variables, e.g. DagRun or TaskInstance, from
producer_function
:Tested this manually. Unfortunately, I don't know how to write a unit test for this.