ueshin commented on code in PR #41924:
URL: https://github.com/apache/spark/pull/41924#discussion_r1260128512


##########
python/pyspark/testing/utils.py:
##########
@@ -382,18 +388,23 @@ def assert_rows_equal(rows1: List[Row], rows2: List[Row]):
         try:
             # rename duplicate columns for sorting
             renamed_df = df.toDF(*[f"_{i}" for i in range(len(df.columns))])
-            renamed_expected = expected.toDF(*[f"_{i}" for i in 
range(len(expected.columns))])
-
             df = renamed_df.sort(renamed_df.columns).toDF(*df.columns)
-            expected = 
renamed_expected.sort(renamed_expected.columns).toDF(*expected.columns)
+            if isinstance(expected, List):
+                expected.sort()

Review Comment:
   ```py
   expected = sorted(expected)
   ```
   
   to avoid updating the input.



##########
python/pyspark/testing/utils.py:
##########
@@ -382,18 +388,23 @@ def assert_rows_equal(rows1: List[Row], rows2: List[Row]):
         try:
             # rename duplicate columns for sorting
             renamed_df = df.toDF(*[f"_{i}" for i in range(len(df.columns))])
-            renamed_expected = expected.toDF(*[f"_{i}" for i in 
range(len(expected.columns))])
-
             df = renamed_df.sort(renamed_df.columns).toDF(*df.columns)
-            expected = 
renamed_expected.sort(renamed_expected.columns).toDF(*expected.columns)
+            if isinstance(expected, List):
+                expected.sort()

Review Comment:
   Btw, I'm wondering Python's `sort` or `sorted` works as same as `df.sort()`. 
   We might want to ask users to make it already sorted when they specify a 
list here.
   cc @allisonwang-db 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to