Github user chenghao-intel commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6104#discussion_r30568419
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/functions.scala ---
    @@ -291,6 +291,269 @@ object functions {
       def max(columnName: String): Column = max(Column(columnName))
     
       
//////////////////////////////////////////////////////////////////////////////////////////////
    +  // Window functions
    +  
//////////////////////////////////////////////////////////////////////////////////////////////
    +
    +  /**
    +   * Window function: returns the lag value of current row of the 
expression,
    +   * null when the current row extends before the beginning of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lag(columnName: String): Column = {
    +    lag(columnName, 1)
    +  }
    +
    +  /**
    +   * Window function: returns the lag value of current row of the column,
    +   * null when the current row extends before the beginning of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lag(e: Column): Column = {
    +    lag(e, 1)
    +  }
    +
    +  /**
    +   * Window function: returns the lag values of current row of the 
expression,
    +   * null when the current row extends before the beginning of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lag(e: Column, count: Int): Column = {
    +    lag(e, count, null)
    +  }
    +
    +  /**
    +   * Window function: returns the lag values of current row of the column,
    +   * null when the current row extends before the beginning of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lag(columnName: String, count: Int): Column = {
    +    lag(columnName, count, null)
    +  }
    +
    +  /**
    +   * Window function: returns the lag values of current row of the column,
    +   * given default value when the current row extends before the beginning
    +   * of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lag(columnName: String, count: Int, defaultValue: Any): Column = {
    +    lag(Column(columnName), count, defaultValue)
    +  }
    +
    +  /**
    +   * Window function: returns the lag values of current row of the 
expression,
    +   * given default value when the current row extends before the beginning
    +   * of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lag(e: Column, count: Int, defaultValue: Any): Column = {
    +    UnresolvedWindowFunction("lag", e.expr :: Literal(count) :: 
Literal(defaultValue) :: Nil)
    +  }
    +
    +  /**
    +   * Window function: returns the lead value of current row of the column,
    +   * null when the current row extends before the end of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lead(columnName: String): Column = {
    +    lead(columnName, 1)
    +  }
    +
    +  /**
    +   * Window function: returns the lead value of current row of the 
expression,
    +   * null when the current row extends before the end of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lead(e: Column): Column = {
    +    lead(e, 1)
    +  }
    +
    +  /**
    +   * Window function: returns the lead values of current row of the column,
    +   * null when the current row extends before the end of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lead(columnName: String, count: Int): Column = {
    +    lead(columnName, count, null)
    +  }
    +
    +  /**
    +   * Window function: returns the lead values of current row of the 
expression,
    +   * null when the current row extends before the end of the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lead(e: Column, count: Int): Column = {
    +    lead(e, count, null)
    +  }
    +
    +  /**
    +   * Window function: returns the lead values of current row of the column,
    +   * given default value when the current row extends before the end of 
the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lead(columnName: String, count: Int, defaultValue: Any): Column = {
    +    lead(Column(columnName), count, defaultValue)
    +  }
    +
    +  /**
    +   * Window function: returns the lead values of current row of the 
expression,
    +   * given default value when the current row extends before the end of 
the window.
    +   *
    +   * @group window_funcs
    +   */
    +  def lead(e: Column, count: Int, defaultValue: Any): Column = {
    +    UnresolvedWindowFunction("lead", e.expr :: Literal(count) :: 
Literal(defaultValue) :: Nil)
    +  }
    +
    +  /**
    +   * Returns a new [[WindowFunctionDefinition]] partitioned by the 
specified column.
    +   * For example:
    +   * {{{
    +   *   // The following 2 are equivalent
    +   *   partitionBy("k1", "k2").orderBy("k3")
    +   *   partitionBy($"K1", $"k2").orderBy($"k3")
    +   * }}}
    +   * @group window_funcs
    +   */
    +  @scala.annotation.varargs
    +  def partitionBy(colName: String, colNames: String*): 
WindowFunctionDefinition = {
    +    new WindowFunctionDefinition().partitionBy(colName, colNames: _*)
    +  }
    +
    +  /**
    +   * Returns a new [[WindowFunctionDefinition]] partitioned by the 
specified column.
    +   * For example:
    +   * {{{
    +   *   partitionBy($"col1", $"col2").orderBy("value")
    +   * }}}
    +   * @group window_funcs
    +   */
    +  @scala.annotation.varargs
    +  def partitionBy(cols: Column*): WindowFunctionDefinition = {
    --- End diff --
    
    I am a little confusing, that's why I put `orderBy` and `partitionBy` in 
both `functions.scala` and `WindowFunctionDefinition`. The `functions.scala` is 
the companion object that you described?
    
    Just be sure you know the following 4 cases are legal:
    `partitionBy("k1").orderBy("k2").rows.preceding(1)`
    `orderBy("k2").partitionBy("k1").rows.preceding(1)`
    `orderBy("k2").rows.preceding(1)`
    `partitionBy("k1").rows.preceding(1)`
    
    And `def partitionBy("k1")` will return a `WindowFunctionDefinition` 
instance whatever within `functions.scala` or `WindowFunctionDefinition.scala`, 
the same for `orderBy("k2")`.


---
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