zhengruifeng commented on code in PR #38847:
URL: https://github.com/apache/spark/pull/38847#discussion_r1035592121
##########
python/pyspark/sql/tests/connect/test_connect_basic.py:
##########
@@ -411,6 +411,48 @@ def test_subquery_alias(self) -> None:
)
self.assertTrue("special_alias" in plan_text)
+ def test_sort(self):
+ # SPARK-41332: test sort
+ query = """
+ SELECT * FROM VALUES
+ (false, 1, NULL), (false, NULL, 2.0), (NULL, 3, 3.0)
+ AS tab(a, b, c)
+ """
+ # +-----+----+----+
+ # | a| b| c|
+ # +-----+----+----+
+ # |false| 1|null|
+ # |false|null| 2.0|
+ # | null| 3| 3.0|
+ # +-----+----+----+
+
+ cdf = self.connect.sql(query)
+ sdf = self.spark.sql(query)
+ self.assert_eq(
+ cdf.sort("a").toPandas(),
+ sdf.sort("a").toPandas(),
+ )
+ self.assert_eq(
+ cdf.sort("c").toPandas(),
+ sdf.sort("c").toPandas(),
+ )
+ self.assert_eq(
+ cdf.sort("b").toPandas(),
+ sdf.sort("b").toPandas(),
+ )
+ self.assert_eq(
+ cdf.sort(cdf.c, "b").toPandas(),
+ sdf.sort(sdf.c, "b").toPandas(),
+ )
+ self.assert_eq(
+ cdf.sort(cdf.c.desc(), "b").toPandas(),
+ sdf.sort(sdf.c.desc(), "b").toPandas(),
+ )
+ self.assert_eq(
+ cdf.sort(cdf.c.desc(), cdf.a.asc()).toPandas(),
+ sdf.sort(sdf.c.desc(), sdf.a.asc()).toPandas(),
Review Comment:
no, never test it before.
let me also add some tests in plan-only test
--
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]