beliefer commented on a change in pull request #27440: [SPARK-27951][SQL]
Support ANSI SQL NTH_VALUE window function
URL: https://github.com/apache/spark/pull/27440#discussion_r376889490
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/window/WindowFunctionFrame.scala
##########
@@ -157,6 +157,38 @@ final class OffsetWindowFunctionFrame(
override def currentUpperBound(): Int = throw new
UnsupportedOperationException()
}
+class FixedOffsetWindowFunctionFrame(
+ target: InternalRow,
+ ordinal: Int,
+ expressions: Array[OffsetWindowFunction],
+ inputSchema: Seq[Attribute],
+ newMutableProjection: (Seq[Expression], Seq[Attribute]) =>
MutableProjection,
+ offset: Int)
+ extends OffsetWindowFunctionFrame(
+ target, ordinal, expressions, inputSchema, newMutableProjection, offset) {
+
+ override def prepare(rows: ExternalAppendOnlyUnsafeRowArray): Unit = {
+ input = rows
+ inputIndex = 0
+ }
+
+ override def write(index: Int, current: InternalRow): Unit = {
Review comment:
Because the behavior of `NTH_VALUE/FIRST_VALUE/LAST_VALUE` more similar to
`LEAD/LAG`, so I make `FixedOffsetWindowFunctionFrame` extends
`OffsetWindowFunctionFrame`. `OffsetWindowFunctionFrame` only to fetch projects
but `UnboundedWindowFunctionFrame` will `update` and `execute` expressions.
If you think so, I can abstract a base class for
`FixedOffsetWindowFunctionFrame` and `OffsetWindowFunctionFrame`.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]