sadhen commented on a change in pull request #32026:
URL: https://github.com/apache/spark/pull/32026#discussion_r605662222



##########
File path: python/pyspark/sql/pandas/types.py
##########
@@ -346,3 +348,29 @@ def _convert_dict_to_map_items(s):
     :return: pandas.Series of lists of (key, value) pairs
     """
     return s.apply(lambda d: list(d.items()) if d is not None else None)
+
+
+def _serialize_pandas_with_udt(s, dt):
+    if isinstance(dt, UserDefinedType):
+        return s.apply(dt.serialize)
+    elif isinstance(dt, ArrayType) and isinstance(dt.elementType, 
UserDefinedType):
+        udt = dt.elementType
+        return s.apply(lambda x: [udt.serialize(f) for f in x])
+    elif isinstance(dt, StructType):
+        raise ValueError("Nested UDT in StructType has not been supported yet")
+    else:
+        # For DataType without UDT, serialization can be skipped
+        return s
+
+
+def _deserialize_pandas_with_udt(s, dt):
+    if isinstance(dt, UserDefinedType):
+        return s.apply(dt.deserialize)
+    elif isinstance(dt, ArrayType) and isinstance(dt.elementType, 
UserDefinedType):
+        udt = dt.elementType
+        return s.apply(lambda x: [udt.deserialize(f) for f in x])
+    elif isinstance(dt, StructType):
+        raise ValueError("Nested UDT in StructType has not been supported yet")
+    else:
+        # For DataType without UDT, serialization can be skipped

Review comment:
       serialization -> deserialization (wait for reviews and will be corrected 
later to minimize CI actions)




-- 
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to