sadhen opened a new pull request #32321:
URL: https://github.com/apache/spark/pull/32321


   ### What changes were proposed in this pull request?
   Fix a bug of Pandas/Spark conversion with Arrow support enabled.
   
   Support DataType with UDT:
   + [x] UDT
   + [x] ArrayType(UDT)
   + [x] <del>StructType(..., UDT, ...)</del>, postponed
   
   
   ``` python
   spark.conf.set("spark.sql.execution.arrow.pyspark.enabled", True)
   from pyspark.testing.sqlutils  import ExamplePoint, ExamplePointUDT
   from pyspark.sql.types import StructType, StructField
   import pandas as pd
   schema = StructType([StructField('point', ExamplePointUDT(), False)])
   pdf = pd.DataFrame({'point': pd.Series([ExamplePoint(1, 1), ExamplePoint(2, 
2)])})
   df = spark.createDataFrame(pdf, schema)
   print(df.toPandas())
   ```
   
   before (because it fallbacks to arrow disabled):
   ```
          point
   0  (0.0,0.0)
   1  (0.0,0.0)
   ```
   
   after:
   ```
          point
   0  (1.0,1.0)
   1  (2.0,2.0)
   ```
   
   
   ### Why are the changes needed?
   Fix a bug.
   
   For UDT without Arrow support, I will create another PR.
   
   
   ### Does this PR introduce _any_ user-facing change?
   Support Python UDT in PySpark now. No user-facing changes.
   
   
   ### How was this patch tested?
   ``` bash
   python/run-tests --testnames pyspark.sql.tests.test_arrow
   ```
   


-- 
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to