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

   ### What changes were proposed in this pull request?
   
   Fixes `createDataFrame` to respect inference and column names.
   
   ### Why are the changes needed?
   
   Currently when a column name list is provided as a schema, the type 
inference result is not taken care of.
   
   As a result, `createDataFrame` from UDT objects with column name list 
doesn't take the UDT type.
   
   For example:
   
   ```py
   >>> from pyspark.ml.linalg import Vectors
   >>> df = spark.createDataFrame([(1.0, 1.0, Vectors.dense(0.0, 5.0)), (0.0, 
2.0, Vectors.dense(1.0, 2.0))], ["label", "weight", "features"])
   >>> df.printSchema()
   root
    |-- label: double (nullable = true)
    |-- weight: double (nullable = true)
    |-- features: struct (nullable = true)
    |    |-- type: byte (nullable = false)
    |    |-- size: integer (nullable = true)
    |    |-- indices: array (nullable = true)
    |    |    |-- element: integer (containsNull = false)
    |    |-- values: array (nullable = true)
    |    |    |-- element: double (containsNull = false)
   ```
   
   , which should be:
   
   ```py
   >>> df.printSchema()
   root
    |-- label: double (nullable = true)
    |-- weight: double (nullable = true)
    |-- features: vector (nullable = true)
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Added 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