ueshin opened a new pull request, #40627:
URL: https://github.com/apache/spark/pull/40627

   ### What changes were proposed in this pull request?
   
   Fix `DataFrame.collect` with null struct.
   
   ### Why are the changes needed?
   
   There is a behavior difference when collecting `null` struct:
   
   In Spark Connect:
   
   ```py
   >>> df = spark.sql("values (1, struct('a' as x)), (2, struct(null as x)), 
(null, null) as t(a, b)")
   >>> df.printSchema()
   root
    |-- a: integer (nullable = true)
    |-- b: struct (nullable = true)
    |    |-- x: string (nullable = true)
   >>> df.show()
   +----+------+
   |   a|     b|
   +----+------+
   |   1|   {a}|
   |   2|{null}|
   |null|  null|
   +----+------+
   
   >>> df.collect()
   [Row(a=1, b=Row(x='a')), Row(a=2, b=Row(x=None)), Row(a=None, b=<Row()>)]
   ```
   
   whereas PySpark:
   
   ```py
   >>> df.collect()
   [Row(a=1, b=Row(x='a')), Row(a=2, b=Row(x=None)), Row(a=None, b=None)]
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   The behavior fix.
   
   ### How was this patch tested?
   
   Added/modified the 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]

Reply via email to