amoghrajesh commented on code in PR #47439:
URL: https://github.com/apache/airflow/pull/47439#discussion_r1986066279


##########
task_sdk/src/airflow/sdk/execution_time/task_runner.py:
##########
@@ -364,6 +364,7 @@ def _xcom_push(ti: RuntimeTaskInstance, key: str, value: 
Any, mapped_length: int
     # It is responsibility of the client to handle any non native object 
serialization.
     # serialize does just that.
     value = serialize(value)
+    value = value["__data__"] if isinstance(value, dict) and "__data__" in 
value else value

Review Comment:
   @ashb do you think it would be another "pair" of deser + ser for such 
objects?
   
   Basically for cases like tuple, we cannot store them in the table after 
getting them via deser, so we will have to serialise them again before storing.
   
   Examples:
   Tuple:
   ```
   s = serialize(("abcd", "efgh"))
   s
   Out[13]: 
   {'__classname__': 'builtins.tuple',
    '__version__': 1,
    '__data__': ['abcd', 'efgh']}
   from airflow.serialization.serde import serialize, deserialize
   deserialize(s)
   Out[15]: ('abcd', 'efgh')
   ```
   
   List:
   ```
   s = serialize(["1", "2", "3"])
   s
   Out[17]: ['1', '2', '3']
   deserialize(s)
   Out[18]: ['1', '2', '3']
   ```
   
   Datetime:
   ```
   from datetime import datetime
   d = datetime(2000, 11, 7, 10, 30)
   serialize(d)
   Out[21]: 
   {'__classname__': 'datetime.datetime',
    '__version__': 2,
    '__data__': {'timestamp': 973573200.0, 'tz': None}}
   deserialize(serialize(d))
   Out[22]: datetime.datetime(2000, 11, 7, 10, 30)
   ```



-- 
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]

Reply via email to