Skip to content

Commit 7ccbf95

Browse files
committed
fix lead and row_number
1 parent 90f121b commit 7ccbf95

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/snowflake/snowpark/functions.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8980,16 +8980,16 @@ def row_number(_emit_ast: bool = True) -> Column:
89808980
... ],
89818981
... schema=["x", "y", "z"]
89828982
... )
8983-
>>> df.select(row_number().over(Window.partition_by(col("X")).order_by(col("Y"))).alias("result")).show()
8984-
------------
8985-
|"RESULT" |
8986-
------------
8987-
|1 |
8988-
|2 |
8989-
|3 |
8990-
|1 |
8991-
|2 |
8992-
------------
8983+
>>> df.select(col("X"), row_number().over(Window.partition_by(col("X")).order_by(col("Y"))).alias("result")).sort("X", "result").show()
8984+
------------------
8985+
|"X" |"RESULT" |
8986+
------------------
8987+
|1 |1 |
8988+
|1 |2 |
8989+
|2 |1 |
8990+
|2 |2 |
8991+
|2 |3 |
8992+
------------------
89938993
<BLANKLINE>
89948994
"""
89958995
return _call_function("row_number", _emit_ast=_emit_ast)
@@ -9058,15 +9058,15 @@ def lead(
90589058
>>> df = session.create_dataframe(
90599059
... [
90609060
... [1, 2, 1],
9061-
... [1, 3, 3],
9061+
... [1, 2, 3],
90629062
... [2, 1, 10],
90639063
... [2, 2, 1],
9064-
... [2, 3, 3],
9064+
... [2, 2, 3],
90659065
... ],
90669066
... schema=["x", "y", "z"]
90679067
... )
9068-
>>> df.select(lead("Z").over(Window.partition_by(col("X")).order_by(col("X"), col("Y"))).alias("result")).collect()
9069-
[Row(RESULT=1), Row(RESULT=3), Row(RESULT=None), Row(RESULT=3), Row(RESULT=None)]
9068+
>>> df.select(lead("Z").over(Window.partition_by(col("X")).order_by(col("Y"))).alias("result")).sort("result").collect()
9069+
[Row(RESULT=None), Row(RESULT=None), Row(RESULT=1), Row(RESULT=3), Row(RESULT=3)]
90709070
"""
90719071
# AST.
90729072
ast = (

0 commit comments

Comments
 (0)