viirya commented on a change in pull request #23900: [SPARK-23836][PYTHON] Add
support for StructType return in Scalar Pandas UDF
URL: https://github.com/apache/spark/pull/23900#discussion_r261053775
##########
File path: python/pyspark/serializers.py
##########
@@ -295,7 +297,33 @@ def create_array(s, t):
raise RuntimeError(error_msg % (s.dtype, t), e)
return array
- arrs = [create_array(s, t) for s, t in series]
+ arrs = []
+ for s, t in series:
+ if t is not None and pa.types.is_struct(t):
+ if not isinstance(s, pd.DataFrame):
+ raise ValueError("A field of type StructType expects a
pandas.DataFrame, "
+ "but got: %s" % str(type(s)))
+
+ # Assign result columns by schema name if user labeled with
strings, else use position
+ struct_arrs = []
+ struct_names = []
+ if assign_cols_by_name and any(isinstance(name, basestring) for
name in s.columns):
Review comment:
not all columns are labeled with string, but any one?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]