Hyukjin Kwon created SPARK-60990:
------------------------------------
Summary: Sort nulls first in Window.orderBy of a column in Spark
Connect Rust as PySpark does
Key: SPARK-60990
URL: https://issues.apache.org/jira/browse/SPARK-60990
Project: Spark
Issue Type: Bug
Components: Connect
Affects Versions: connect-rust-4.3.0
Reporter: Hyukjin Kwon
In PySpark, {{Window.orderBy}} and {{WindowSpec.orderBy}} order by a column
name or a Column that is not a sort order ascending with nulls first, as
{{SortOrder(expr)}} defaults to and as Spark sorts ascending. The Rust-backed
Python client orders such a column ascending with nulls last, so window
functions over a column with nulls give other results. For example, over the
values NULL, 1 and 2 of {{o}}:
{code:python}
df.select("o", F.row_number().over(Window.partitionBy("g").orderBy("o")))
{code}
gives the rows (NULL, 1), (1, 2), (2, 3) in PySpark 4.3.0, and (1, 1), (2, 2),
(NULL, 3) in the client. {{rank}}, {{lag}}, running aggregates and the other
functions over such a window differ the same way. Sort nulls first as PySpark
does.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]