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

    https://github.com/apache/spark/pull/15513#discussion_r85628048
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
 ---
    @@ -372,22 +372,29 @@ abstract class OffsetWindowFunction
     }
     
     /**
    - * The Lead function returns the value of 'x' at the 'offset'th row after 
the current row in
    + * The Lead function returns the value of `input` at the `offset`th row 
after 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 after the current row.
    + * @param input expression to evaluate `offset` rows after the current row.
      * @param offset rows to jump ahead in the partition.
      * @param default to use when the offset is larger than the window. The 
default value is null.
      */
    -@ExpressionDescription(usage =
    -  """_FUNC_(input, offset, default) - LEAD returns the value of 'x' at the 
'offset'th row
    -     after 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 last 
row of the window
    -     does not have any subsequent row), 'default' is returned.""")
    +@ExpressionDescription(
    +  usage = """
    +    _FUNC_(input[, offset[, default]]) - Returns the value of `input` at 
the `offset`th row
    +      after 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 an offset row (e.g., when the 
offset is 1, the last
    +      row of the window does not have any subsequent 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(
            lead("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(
            lead("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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to