Github user davies commented on a diff in the pull request: https://github.com/apache/spark/pull/11444#discussion_r54979408 --- Diff: python/pyspark/sql/context.py --- @@ -50,18 +50,56 @@ def _monkey_patch_RDD(sqlContext): def toDF(self, schema=None, sampleRatio=None): """ - Converts current :class:`RDD` into a :class:`DataFrame` + Converts current :class:`RDD` into a :class:`DataFrame` according to the given schema. + If the given schema is None or just column names, the schema will be inferred by scanning + the data in this RDD according to the sampleRatio. - This is a shorthand for ``sqlContext.createDataFrame(rdd, schema, sampleRatio)`` + Note that, the given schema must match the real data, or exception will be thrown at + runtime. If the given schema is not StructType, it will be wrapped into a StructType as + its only field, and the field name will be "value", each record will also be wrapped into a + tuple, which can be converted to row later. - :param schema: a StructType or list of names of columns + :param schema: a :class:`DataType` or a datatype string or list of names of columns --- End diff -- Do you want to support a schema string like this? "name age"
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org