GitHub user JasonMWhite opened a pull request:

    https://github.com/apache/spark/pull/12470

    [SPARK-14700] [Python] adding SQL Row equality and inequality overrides

    ## What changes were proposed in this pull request?
    
    This PR adds equality and inequality overrides to `pyspark.sql.Row`. 
Without this override, `Row` simply uses the equality operator of `tuple`, 
which doesn't consider the private member `__fields__` of Row to determine the 
implicit ordering needed to compare the tuples correctly.
    
    Without this PR, we get seemingly illogical equality checks like:
    ```
    Row(a=1) == Row(b=1) # True
    r1 == Row('b', 'a')(2, 1) # Row(b=2, a=1)
    r1 == Row(b=2, a=1) # False
    r1 == Row(a=2, b=1) # True
    ```
    
    ## How was this patch tested?
    
    Unit tests were added to `pyspark/sql/types.py` in the `Row` docstring. A 
handful of newly failing tests in `pyspark/sql/tests.py` were fixed.
    
    This PR is my original work and I license the work to the project under the 
project's open source license.
    
    @davies @rxin Mind having a look?


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/JasonMWhite/spark row_equality

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/12470.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #12470
    
----
commit 986c8f27f34c53d44df59296042605d373bae7e7
Author: Jason White <[email protected]>
Date:   2016-04-18T05:10:51Z

    adding SQL Row equality and inequality overrides

----


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