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

    https://github.com/apache/flink/pull/3743#discussion_r112605911
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/windows.scala
 ---
    @@ -22,6 +22,126 @@ import org.apache.flink.table.expressions.{Expression, 
ExpressionParser}
     import org.apache.flink.table.plan.logical._
     
     /**
    +  * An over window specification.
    +  *
    +  * Over window is similar to the traditional OVER SQL.
    +  */
    +class OverWindow {
    +
    +  private[flink] var alias: Expression = _
    +  private[flink] var partitionBy: Seq[Expression] = Seq[Expression]()
    +  private[flink] var orderBy: Expression = _
    +  private[flink] var preceding: Expression = _
    +  private[flink] var following: Expression = null
    +
    +  /**
    +    * Assigns an alias for this window that the following `select()` 
clause can refer to.
    +    *
    +    * @param alias alias for this over window
    +    * @return this over window
    +    */
    +  def as(alias: String): OverWindow = 
as(ExpressionParser.parseExpression(alias))
    +
    +  /**
    +    * Assigns an alias for this window that the following `select()` 
clause can refer to.
    +    *
    +    * @param alias alias for this over window
    +    * @return this over window
    +    */
    +  def as(alias: Expression): OverWindow = {
    +    this.alias = alias
    +    this
    +  }
    +
    +  /**
    +    * Partitions the elements on some partition keys.
    +    *
    +    * @param partitionBy
    +    * @return this over window
    +    */
    +  def partitionBy(partitionBy: String): OverWindow = {
    +    this.partitionBy(ExpressionParser.parseExpression(partitionBy))
    +  }
    +
    +  /**
    +    * Partitions the elements on some partition keys.
    +    *
    +    * @param partitionBy
    +    * @return this over window
    +    */
    +  def partitionBy(partitionBy: Expression*): OverWindow = {
    +    this.partitionBy = partitionBy
    +    this
    +  }
    +
    +
    +  /**
    +    * Specifies the time mode.
    +    *
    +    * @param orderBy For streaming tables call [[orderBy 'rowtime or 
orderBy 'proctime]]
    +    *                to specify time mode.
    +    * @return this over window
    +    */
    +  def orderBy(orderBy: String): OverWindow = {
    +    this.orderBy(ExpressionParser.parseExpression(orderBy))
    +  }
    +
    +  /**
    +    * Specifies the time mode.
    +    *
    +    * @param orderBy For streaming tables call [[orderBy 'rowtime or 
orderBy 'proctime]]
    +    *                to specify time mode.
    +    * @return this over window
    +    */
    +  def orderBy(orderBy: Expression): OverWindow = {
    +    this.orderBy = orderBy
    +    this
    +  }
    +
    +  /**
    +    * Set the preceding offset (based on time or row-count intervals) for 
over window
    +    *
    +    * @param preceding forward offset that relative to the current row
    +    * @return this over window
    +    */
    +  def preceding(preceding: String): OverWindow = {
    +    this.preceding(ExpressionParser.parseExpression(preceding))
    +  }
    +
    +  /**
    +    * Set the preceding offset (based on time or row-count intervals) for 
over window
    +    *
    +    * @param preceding forward offset that relative to the current row
    +    * @return this over window
    +    */
    +  def preceding(preceding: Expression): OverWindow = {
    +    this.preceding = preceding
    +    this
    +  }
    +
    +  /**
    +    * Set the following offset (based on time or row-count intervals) for 
over window
    +    *
    +    * @param following subsequent offset that relative to the current row
    +    * @return this over window
    +    */
    +  def following(following: String): OverWindow = {
    --- End diff --
    
    That's good idea. +1


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

Reply via email to