uranusjr commented on a change in pull request #22396:
URL: https://github.com/apache/airflow/pull/22396#discussion_r837297952
##########
File path: airflow/models/mappedoperator.py
##########
@@ -225,7 +226,7 @@ def expand(self, **mapped_kwargs: "Mappable") ->
"MappedOperator":
class MappedOperator(AbstractOperator):
"""Object representing a mapped operator in a DAG."""
- operator_class: Union[Type["BaseOperator"], str]
+ operator_class: Union[Type["BaseOperator"], Dict[str, Any]]
Review comment:
The dict variant is actually just an optimisation, we could implement
unmap like this instead:
```python
op = SerializedBaseOperator(task_id=self.task_id, _airflow_from_mapped=True)
encoded = SerializedBaseOperator.serialize_operator(self)
data = {k: v for k, v in encoded.items() if k in
BaseOperator.get_serialized_fields()}
SerializedBaseOperator.populate_operator(op, data)
return op
```
If we want to avoid re-serialising, I personally prefer using Union here
since it’s more obvious that exactly one usage of `operator_class` makes sense
for non-serialised and serialised operator. Perhaps we could heavily comment
this to make it clearer? Or have a “proper” `SerializedMappedOperator` class
instead?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]