zhengruifeng commented on code in PR #39835:
URL: https://github.com/apache/spark/pull/39835#discussion_r1092847784
##########
python/pyspark/sql/connect/types.py:
##########
@@ -108,6 +109,17 @@ def pyspark_types_to_proto_types(data_type: DataType) ->
pb2.DataType:
elif isinstance(data_type, ArrayType):
ret.array.element_type.CopyFrom(pyspark_types_to_proto_types(data_type.elementType))
ret.array.contains_null = data_type.containsNull
+ elif isinstance(data_type, UserDefinedType):
+ json_value = data_type.jsonValue()
+ ret.udt.type = "udt"
+ if "class" in json_value:
+ # Scala/Java UDT
+ ret.udt.jvm_class = json_value["class"]
+ else:
+ # Python UDT
+ ret.udt.serialized_python_class = json_value["serializedClass"]
+ ret.udt.python_class = json_value["pyClass"]
Review Comment:
refer to the `jsonValue` and `fromJson` methods in Python, the `pyClass` is
a required field for Python UDT, otherwise it can not ser/deser in JSON format.
https://github.com/apache/spark/blob/51b04406028e14fbe1986f6a3ffc67853bd82935/python/pyspark/sql/types.py#L1098-L1130
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]