ueshin opened a new pull request, #42161:
URL: https://github.com/apache/spark/pull/42161
### What changes were proposed in this pull request?
Fixes `ArrowStreamPandasUDFSerializer` to accept no-column pandas DataFrame.
```py
>>> def _scalar_f(id):
... return pd.DataFrame(index=id)
...
>>> scalar_f = pandas_udf(_scalar_f, returnType=StructType())
>>> df = spark.range(3).withColumn("f", scalar_f(col("id")))
>>> df.printSchema()
root
|-- id: long (nullable = false)
|-- f: struct (nullable = true)
>>> df.show()
+---+---+
| id| f|
+---+---+
| 0| {}|
| 1| {}|
| 2| {}|
+---+---+
```
### Why are the changes needed?
The above query fails with the following error:
```py
>>> df.show()
org.apache.spark.api.python.PythonException: Traceback (most recent call
last):
...
ValueError: not enough values to unpack (expected 2, got 0)
```
### Does this PR introduce _any_ user-facing change?
Yes, Pandas UDF will accept no-column pandas DataFrame.
### How was this patch tested?
Added related tests.
--
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]