You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/07/08 22:00:23 UTC

[GitHub] [spark] xinrong-databricks commented on a diff in pull request #36893: [SPARK-39494][PYTHON] Support `createDataFrame` from a list of scalars

xinrong-databricks commented on code in PR #36893:
URL: https://github.com/apache/spark/pull/36893#discussion_r917160564


##########
python/pyspark/sql/session.py:
##########
@@ -1023,6 +1023,12 @@ def prepare(obj: Any) -> Any:
 
         if isinstance(data, RDD):
             rdd, struct = self._createFromRDD(data.map(prepare), schema, samplingRatio)
+        elif isinstance(data, list) and schema is None:

Review Comment:
   Respect the existing behavior when `schema` is given.
   
   Specifically, 
   ```py
   >>> spark.createDataFrame([1, 2], schema='int')
   DataFrame[value: int]
   
   >>> spark.createDataFrame([(1,), (2,)], schema='int')
   ...
   TypeError: field value: IntegerType() can not accept object (1,) in type <class 'tuple'>
   ```
   
   Adjusting the inconsistency above is out of the scope of this PR and ought to be a follow-up.



-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org