beliefer commented on a change in pull request #29800:
URL: https://github.com/apache/spark/pull/29800#discussion_r503179138



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
##########
@@ -347,18 +341,51 @@ abstract class OffsetWindowFunction
   val default: Expression
 
   /**
-   * (Foldable) expression that contains the number of rows between the 
current row and the row
-   * where the input expression is evaluated.
+   * (Foldable) expression that contains the number of rows between the 
starting row (current row
+   * if isRelative=true, or the first row of the window frame otherwise) and 
the row where the
+   * input expression is evaluated.
    */
-  val offset: Expression
+  val offsetExpr: Expression
 
   /**
-   * Direction of the number of rows between the current row and the row where 
the input expression
-   * is evaluated.
+   * Direction of the number of rows between the current row or the first row 
of the entire
+   * window partition and the row where the input expression is evaluated.
    */
   val direction: SortDirection
 
-  override def children: Seq[Expression] = Seq(input, offset, default)
+  /**
+   * An optional specification that indicates the offset window function 
should skip null values in
+   * the determination of which row to use.
+   */
+  val ignoreNulls: Boolean
+
+  /**
+   * Whether the offset is starts with the current row. If `isRelative` is 
true, `offset` means
+   * the offset is start with the current row. otherwise, the offset is starts 
with the first
+   * row of the entire window frame.
+   */
+  val isRelative: Boolean = true
+
+  lazy val boundary = direction match {
+    case Ascending => offsetExpr
+    case Descending => UnaryMinus(offsetExpr) match {
+      case e: Expression if e.foldable => Literal.create(e.eval(EmptyRow), 
e.dataType)
+      case o => o
+    }
+  }
+
+  lazy val fakeFrame = SpecifiedWindowFrame(RowFrame, boundary, boundary)

Review comment:
       Just tell every one that this frame don't play the real role of the 
frame, just a fake.

##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
##########
@@ -347,18 +341,51 @@ abstract class OffsetWindowFunction
   val default: Expression
 
   /**
-   * (Foldable) expression that contains the number of rows between the 
current row and the row
-   * where the input expression is evaluated.
+   * (Foldable) expression that contains the number of rows between the 
starting row (current row
+   * if isRelative=true, or the first row of the window frame otherwise) and 
the row where the
+   * input expression is evaluated.
    */
-  val offset: Expression
+  val offsetExpr: Expression
 
   /**
-   * Direction of the number of rows between the current row and the row where 
the input expression
-   * is evaluated.
+   * Direction of the number of rows between the current row or the first row 
of the entire
+   * window partition and the row where the input expression is evaluated.
    */
   val direction: SortDirection
 
-  override def children: Seq[Expression] = Seq(input, offset, default)
+  /**
+   * An optional specification that indicates the offset window function 
should skip null values in
+   * the determination of which row to use.
+   */
+  val ignoreNulls: Boolean
+
+  /**
+   * Whether the offset is starts with the current row. If `isRelative` is 
true, `offset` means
+   * the offset is start with the current row. otherwise, the offset is starts 
with the first
+   * row of the entire window frame.
+   */
+  val isRelative: Boolean = true
+
+  lazy val boundary = direction match {

Review comment:
       I got it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to