amaliujia commented on code in PR #38847:
URL: https://github.com/apache/spark/pull/38847#discussion_r1035589632
##########
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):
Review Comment:
big +1
##########
python/pyspark/sql/connect/column.py:
##########
@@ -307,7 +305,21 @@ def __str__(self) -> str:
return str(self.ref) + " ASC" if self.ascending else " DESC"
def to_plan(self, session: "SparkConnectClient") -> proto.Expression:
- return self.ref.to_plan(session)
+ # TODO: move SortField from relations.proto to expression.proto
Review Comment:
Nit: better to have a JIRA link here. I usually do TODO(SPARK-xxxx)
##########
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:
we don't have null last and null first 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]