turbaszek commented on issue #11983:
URL: https://github.com/apache/airflow/issues/11983#issuecomment-759269669
It seems that in 2.0 you can use `output` attribute to do what you want:
```py
class CustomOp(BaseOperator):
@apply_defaults
def __init__(self, **kwargs):
super().__init__(**kwargs)
def execute(self, context: Any):
return [{"a": 1, "b": 2} for _ in range(5)]
class CustomOp2(BaseOperator):
template_fields = ["xs"]
@apply_defaults
def __init__(self, xs, **kwargs):
super().__init__(**kwargs)
self.xs = xs
def execute(self, context: Any):
self.log.info(self.xs)
for x in self.xs:
self.log.info(x)
with DAG(
'test_xcom_native',
default_args=default_args
) as dag2:
op = CustomOp(task_id="generate")
CustomOp2(task_id="print", xs=op.output)
```
and you get:
```
[2021-01-13 07:44:12,266] {xcom.py:52} INFO - [{'a': 1, 'b': 2}, {'a': 1,
'b': 2}, {'a': 1, 'b': 2}, {'a': 1, 'b': 2}, {'a': 1, 'b': 2}]
[2021-01-13 07:44:12,267] {xcom.py:54} INFO - {'a': 1, 'b': 2}
[2021-01-13 07:44:12,269] {xcom.py:54} INFO - {'a': 1, 'b': 2}
[2021-01-13 07:44:12,270] {xcom.py:54} INFO - {'a': 1, 'b': 2}
[2021-01-13 07:44:12,271] {xcom.py:54} INFO - {'a': 1, 'b': 2}
[2021-01-13 07:44:12,272] {xcom.py:54} INFO - {'a': 1, 'b': 2}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]