BryanCutler commented on issue #24614: [SPARK-27712][PySpark][SQL] Returns 
correct schema even under different column order when creating dataframe
URL: https://github.com/apache/spark/pull/24614#issuecomment-493608601
 
 
   The problem I when using a positional schema when constructing `Row`s using 
a dict is that the `Row` constructor sorts the fields, so any sense of position 
is lost.  For example:
   
   This works
   ```python
   data = [Row(k=i, v=str(i)) for i in range(100)]
   rdd = spark.sparkContext.parallelize(data, 5)
   # field names can differ.
   df = rdd.toDF(" a: int, b: string ")
   ```
   
   This fails
   ```python
   data = [Row(z=i, y=str(i)) for i in range(100)]
   rdd = spark.sparkContext.parallelize(data, 5)
   # field names can differ.
   df = rdd.toDF(" a: int, b: string ")
   ```
   
   where the only difference is the field name from `Row`, so it really isn't 
positional.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

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

Reply via email to