Open michal-cech opened 2 years ago
Thanks for opening your first issue here! Be sure to follow the issue template!
To add, I understand that I can use another task like this:
@task
def extract_input(p):
return p['list']
p_list = extract_input(parameters)
print_elements.expand(element=p_list)
and it will work, but I wonder if the described behaviour is intended or if it is a bug / true inconsistency in behaviour.
FWIW, this was a conscious decision when implementing AIP-42 at the time. See https://github.com/apache/airflow/pull/21930 description.
cc @uranusjr if there is any additional color to add.
There are actually two levels in this issue. First, the square bracket syntax does not mean dictionary access here. It means accessing a different XCom pushed by the parent task.
The second level is we do not support expanding a task against arbitrary XCom push, only the return value, as mentioned above. This is the direct cause to the exception, but not related to what the user is actually trying to do here.
The current square bracket syntax is terrible (sorry if you were the one who invented it), but unfortunately we can’t do anything about it at the time. I’ll re-label this as a documentation issue so we can add some warnings in the task-mapping doc page. Feel free to work on it.
Apache Airflow version
2.3.3 (latest released)
What happened
When tasks return dictionary value, it is possible to access the value on the DAG level by using
return_value['key']
. This does not seem to be possible when using the newly addedexpand
functionality. It fails to load the DAG with (see example below):ValueError: cannot map over XCom with custom key 'list' from <Task(_PythonDecoratedOperator): params>
What you think should happen instead
I think Airflow should behave in a consistent way while using
and
How to reproduce
Operating System
Ubuntu 20.0.4
Versions of Apache Airflow Providers
No response
Deployment
Docker-Compose
Deployment details
No response
Anything else
No response
Are you willing to submit PR?
Code of Conduct