Github user HyukjinKwon commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15513#discussion_r85628075
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
 ---
    @@ -401,22 +408,29 @@ case class Lead(input: Expression, offset: 
Expression, default: Expression)
     }
     
     /**
    - * The Lag function returns the value of 'x' at the 'offset'th row before 
the current row in
    + * The Lag function returns the value of `input` at the `offset`th row 
before the current row in
      * the window. Offsets start at 0, which is the current row. The offset 
must be constant
    - * integer value. The default offset is 1. When the value of 'x' is null 
at the 'offset'th row,
    - * null is returned. If there is no such offset row, the default 
expression is evaluated.
    + * integer value. The default offset is 1. When the value of `input` is 
null at the `offset`th row,
    + * null is returned. If there is no such offset row, the `default` 
expression is evaluated.
      *
    - * @param input expression to evaluate 'offset' rows before the current 
row.
    + * @param input expression to evaluate `offset` rows before the current 
row.
      * @param offset rows to jump back in the partition.
      * @param default to use when the offset row does not exist.
      */
    -@ExpressionDescription(usage =
    -  """_FUNC_(input, offset, default) - LAG returns the value of 'x' at the 
'offset'th row
    -     before the current row in the window.
    -     The default value of 'offset' is 1 and the default value of 'default' 
is null.
    -     If the value of 'x' at the 'offset'th row is null, null is returned.
    -     If there is no such offset row (e.g. when the offset is 1, the first 
row of the window
    -     does not have any previous row), 'default' is returned.""")
    +@ExpressionDescription(
    +  usage = """
    +    _FUNC_(input[, offset[, default]]) - Returns the value of `input` at 
the `offset`th row
    +      before the current row in the window. The default value of `offset` 
is 1 and the default
    +      value of `default` is null. If the value of `input` at the 
`offset`th row is null,
    +      null is returned. If there is no such offset row (e.g., when the 
offset is 1, the first
    +      row of the window does not have any previous row), `default` is 
returned.
    +  """,
    +  extended = """
    +    Arguments:
    +      input - an expression of any type.
    +      offset - a numeric expression. Default is 1.
    +      default - an expression of any type. Default is null.
    --- End diff --
    
    ```scala
           {
          val df = Seq((1, "1"), (2, "2"), (1, "1"), (2, "2")).toDF("key", 
"value")
            .selectExpr("array(value) as value", "key")
          df.select(
            lag("value", 
1).over(Window.partitionBy($"key").orderBy($"value"))).show()
        }
        {
          val df = Seq((1, "1"), (2, "2"), (1, "1"), (2, "2")).toDF("key", 
"value")
            .selectExpr("struct(value) as value", "key")
          df.select(
            lag("value", 
1).over(Window.partitionBy($"key").orderBy($"value"))).show()
        }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to