Skip to content

Commit

Permalink
[SPARK-26451][SQL] Change lead/lag argument name from count to offset
Browse files Browse the repository at this point in the history
## What changes were proposed in this pull request?

Change aligns argument name with that in Scala version and documentation.

## How was this patch tested?

(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
(If this patch involves UI changes, please attach a screenshot; otherwise, remove this)

Please review http://spark.apache.org/contributing.html before opening a pull request.

Closes #23357 from deepyaman/patch-1.

Authored-by: deepyaman <deepyaman.datta@utexas.edu>
Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
  • Loading branch information
deepyaman authored and HyukjinKwon committed Dec 27, 2018
1 parent add287f commit 68496c1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions python/pyspark/sql/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ def factorial(col):
# --------------- Window functions ------------------------

@since(1.4)
def lag(col, count=1, default=None):
def lag(col, offset=1, default=None):
"""
Window function: returns the value that is `offset` rows before the current row, and
`defaultValue` if there is less than `offset` rows before the current row. For example,
Expand All @@ -807,15 +807,15 @@ def lag(col, count=1, default=None):
This is equivalent to the LAG function in SQL.
:param col: name of column or expression
:param count: number of row to extend
:param offset: number of row to extend
:param default: default value
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.lag(_to_java_column(col), count, default))
return Column(sc._jvm.functions.lag(_to_java_column(col), offset, default))


@since(1.4)
def lead(col, count=1, default=None):
def lead(col, offset=1, default=None):
"""
Window function: returns the value that is `offset` rows after the current row, and
`defaultValue` if there is less than `offset` rows after the current row. For example,
Expand All @@ -824,11 +824,11 @@ def lead(col, count=1, default=None):
This is equivalent to the LEAD function in SQL.
:param col: name of column or expression
:param count: number of row to extend
:param offset: number of row to extend
:param default: default value
"""
sc = SparkContext._active_spark_context
return Column(sc._jvm.functions.lead(_to_java_column(col), count, default))
return Column(sc._jvm.functions.lead(_to_java_column(col), offset, default))


@since(1.4)
Expand Down

0 comments on commit 68496c1

Please sign in to comment.