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

    https://github.com/apache/spark/pull/16928#discussion_r120023340
  
    --- Diff: python/pyspark/sql/readwriter.py ---
    @@ -191,10 +191,13 @@ def json(self, path, schema=None, 
primitivesAsString=None, prefersDecimal=None,
             :param mode: allows a mode for dealing with corrupt records during 
parsing. If None is
                          set, it uses the default value, ``PERMISSIVE``.
     
    -                *  ``PERMISSIVE`` : sets other fields to ``null`` when it 
meets a corrupted \
    -                  record and puts the malformed string into a new field 
configured by \
    -                 ``columnNameOfCorruptRecord``. When a schema is set by 
user, it sets \
    -                 ``null`` for extra fields.
    +                * ``PERMISSIVE`` : sets other fields to ``null`` when it 
meets a corrupted \
    +                 record, and puts the malformed string into a field 
configured by \
    +                 ``columnNameOfCorruptRecord``. To keep corrupt records, 
an user can set \
    +                 a string type field named ``columnNameOfCorruptRecord`` 
in an user-defined \
    +                 schema. If a schema does not have the field, it drops 
corrupt records during \
    +                 parsing. When inferring a schema, it implicitly adds a \
    +                 ``columnNameOfCorruptRecord`` field in an output schema.
    --- End diff --
    
    (Sorry for interrupting) yea, it should be consistent and we probably 
should change. Probably, we should also consider the records with tokens less 
or more than the schema as malformed records in PERMISSIVE mode rafher than 
filling some of it. @cloud-fan raised this issue before and I had a talk with 
some data analysists. It looked some agree and others do not. So, I just 
decided to not change the current behaviour for now.
    
    To cut it short, the reason (I assume) is I could not imagine a simple 
common case that fails to parse CSV (not during conversion) for the current 
implementation. If there are, we should match the behaviour. 
    
    I am currently outside and this is my phone. I will double check this when 
I get to my computer but this will be correct if I haven't missed some changes 
in this code path.


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