Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7453#discussion_r35819849
  
    --- Diff: python/pyspark/sql/context.py ---
    @@ -277,6 +277,59 @@ def applySchema(self, rdd, schema):
     
             return self.createDataFrame(rdd, schema)
     
    +    def _createFromRDD(self, rdd, schema, samplingRatio):
    +        if schema is None or isinstance(schema, (list, tuple)):
    +            struct = self._inferSchema(rdd, samplingRatio)
    +            converter = _create_converter(struct)
    +            rdd = rdd.map(converter)
    +            if isinstance(schema, (list, tuple)):
    +                for i, name in enumerate(schema):
    +                    struct.fields[i].name = name
    +                    struct.names[i] = name
    +            schema = struct
    +
    +        elif isinstance(schema, StructType):
    +            # take the first few rows to verify schema
    +            rows = rdd.take(10)
    +            for row in rows:
    +                _verify_type(row, schema)
    +
    +        else:
    +            raise TypeError("schema should be StructType or list or None")
    --- End diff --
    
    include `schema` in the error message


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to