zhengruifeng commented on code in PR #39090:
URL: https://github.com/apache/spark/pull/39090#discussion_r1051700063
##########
python/pyspark/sql/connect/column.py:
##########
@@ -437,35 +437,38 @@ def to_plan(self, session: "SparkConnectClient") ->
proto.Expression:
class SortOrder(Expression):
- def __init__(self, child: Expression, ascending: bool = True, nullsLast:
bool = False) -> None:
+ def __init__(self, child: Expression, ascending: bool = True, nullsFirst:
bool = True) -> None:
super().__init__()
self._child = child
self._ascending = ascending
- self._nullsLast = nullsLast
+ self._nullsFirst = nullsFirst
def __repr__(self) -> str:
return (
str(self._child)
+ (" ASC" if self._ascending else " DESC")
- + (" NULLS LAST" if self._nullsLast else " NULLS FIRST")
+ + (" NULLS FIRST" if self._nullsFirst else " NULLS LAST")
)
def to_plan(self, session: "SparkConnectClient") -> proto.Expression:
- # TODO(SPARK-41334): move SortField from relations.proto to
expressions.proto
- sort = proto.Sort.SortField()
- sort.expression.CopyFrom(self._child.to_plan(session))
+ sort = proto.Expression()
+ sort.sort_order.child.CopyFrom(self._child.to_plan(session))
if self._ascending:
- sort.direction = proto.Sort.SortDirection.SORT_DIRECTION_ASCENDING
+ sort.sort_order.direction = (
+
proto.Expression.SortOrder.SortDirection.SORT_DIRECTION_ASCENDING
+ )
else:
- sort.direction = proto.Sort.SortDirection.SORT_DIRECTION_DESCENDING
+ sort.sort_order.direction = (
+
proto.Expression.SortOrder.SortDirection.SORT_DIRECTION_DESCENDING
+ )
- if self._nullsLast:
- sort.nulls = proto.Sort.SortNulls.SORT_NULLS_LAST
+ if self._nullsFirst:
+ sort.sort_order.null_ordering =
proto.Expression.SortOrder.NullOrdering.SORT_NULLS_FIRST
else:
- sort.nulls = proto.Sort.SortNulls.SORT_NULLS_FIRST
+ sort.sort_order.null_ordering =
proto.Expression.SortOrder.NullOrdering.SORT_NULLS_LAST
- return cast(proto.Expression, sort)
Review Comment:
thanks, will update
--
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]