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

    https://github.com/apache/spark/pull/12470#discussion_r60122211
  
    --- Diff: python/pyspark/sql/types.py ---
    @@ -1448,6 +1448,54 @@ def __repr__(self):
             else:
                 return "<Row(%s)>" % ", ".join(self)
     
    +    def __eq__(self, other):
    +        """
    +        Test for equality with `other`.
    +
    +        :param other: other Row for comparison
    +
    +        >>> Row(name="Alice", age=11) == Row(age=11, name="Alice")
    +        True
    +        >>> R1 = Row('a', 'b')
    +        >>> R2 = Row('b', 'a')
    +        >>> R1(1, 2) == R2(2, 1)
    --- End diff --
    
    I don't think I agree with this approach. It comes down to whether or not 
the ordering of the columns in the schema should matter, and I don't believe it 
should. If the ordering of the fields matters, then the Row constructor 
probably shouldn't automatically sort the provided kwargs alphabetically. This 
leads to very weird and nonintuitive results like:
    ```
    r1 = df.select('b', 'a').collect()[0]
    r1  # Row(b=2, a=1)
    r1 == Row(b=2, a=1) # False
    ```
    The only way to test equality properly would then be:
    ```
    r1 == Row('b', 'a')(2, 1) # True
    ```
    What benefit do we gain by making column ordering a factor in Row equality?


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