You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "ueshin (via GitHub)" <gi...@apache.org> on 2023/07/11 18:39:25 UTC

[GitHub] [spark] ueshin commented on a diff in pull request #41924: [SPARK-44364] [PYTHON] Add support for List[Row] data type for expected

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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org