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

    https://github.com/apache/spark/pull/2716#discussion_r19384056
  
    --- Diff: python/pyspark/sql.py ---
    @@ -995,19 +1038,22 @@ def registerFunction(self, name, f, 
returnType=StringType()):
                                           self._sc._javaAccumulator,
                                           returnType.json())
     
    -    def inferSchema(self, rdd):
    +    def inferSchema(self, rdd, samplingRatio=None):
             """Infer and apply a schema to an RDD of L{Row}.
     
    -        We peek at the first row of the RDD to determine the fields' names
    -        and types. Nested collections are supported, which include array,
    -        dict, list, Row, tuple, namedtuple, or object.
    +        If `samplingRatio` is presented, it infer schema by all of the 
sampled
    +        dataset.
     
    -        All the rows in `rdd` should have the same type with the first one,
    -        or it will cause runtime exceptions.
    +        Otherwise, it peeks first few rows of the RDD to determine the 
fields'
    +        names and types. Nested collections are supported, which include 
array,
    +        dict, list, Row, tuple, namedtuple, or object.
     
             Each row could be L{pyspark.sql.Row} object or namedtuple or 
objects,
             using dict is deprecated.
     
    +        If some of rows has different types with inferred types, it may 
cause
    +        runtime exceptions.
    --- End diff --
    
    When `samplingRatio` is specified, the schema is inferred by looking at the 
types of each row in the sampled dataset.  Otherwise, the first 100 rows of the 
RDD are inspected. Nested collections are supported, which can include array, 
dict, list, Row, tuple, namedtuple, or object.
    
    Each row could be L{pyspark.sql.Row} object or namedtuple or objects.  
Using top level dicts is deprecated, as this datatype is used to represent Maps.
     
    If a single column has multiple distinct inferred types, it may cause 
runtime exceptions.



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