beliefer commented on a change in pull request #29800: URL: https://github.com/apache/spark/pull/29800#discussion_r502165838
########## File path: sql/core/src/main/scala/org/apache/spark/sql/execution/window/WindowFunctionFrame.scala ########## @@ -151,10 +169,69 @@ final class OffsetWindowFunctionFrame( } inputIndex += 1 } +} - override def currentLowerBound(): Int = throw new UnsupportedOperationException() +/** + * The unbounded offset window frame calculates frames containing NTH_VALUE statements. + * The unbounded offset window frame return the same value for all rows in the window partition. + */ +class UnboundedOffsetWindowFunctionFrame( + target: InternalRow, + ordinal: Int, + expressions: Array[OffsetWindowSpec], + inputSchema: Seq[Attribute], + newMutableProjection: (Seq[Expression], Seq[Attribute]) => MutableProjection, + offset: Int) + extends OffsetWindowFunctionFrameBase( + target, ordinal, expressions, inputSchema, newMutableProjection, offset) { - override def currentUpperBound(): Int = throw new UnsupportedOperationException() + override def prepare(rows: ExternalAppendOnlyUnsafeRowArray): Unit = { + super.prepare(rows) + if (inputIndex >= 0 && inputIndex < input.length) { + val r = WindowFunctionFrame.getNextOrNull(inputIterator) + projection(r) + } else { + fillDefaultValue(EmptyRow) + } + } + + override def write(index: Int, current: InternalRow): Unit = { + // The results are the same for each row in the partition, and have been evaluated in prepare. + // Don't need to recalculate here. + } +} + +/** + * The unbounded preceding offset window frame calculates frames containing NTH_VALUE statements. + * The unbounded preceding offset window frame return the same value for rows which index + * (starting from 1) equal to or greater than offset in the window partition. + */ +class UnboundedPrecedingOffsetWindowFunctionFrame( Review comment: Because the current `WindowFunctionFrame` is for data row by row. ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org