vitaliili-db commented on code in PR #43236:
URL: https://github.com/apache/spark/pull/43236#discussion_r1350542219


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/window/WindowFunctionFrame.scala:
##########
@@ -200,15 +200,19 @@ class FrameLessOffsetWindowFunctionFrame(
 
   override def prepare(rows: ExternalAppendOnlyUnsafeRowArray): Unit = {
     resetStates(rows)
-    if (ignoreNulls) {
-      findNextRowWithNonNullInput()
+    if (Math.abs(offset) > rows.length) {
+      inputIndex = offset
     } else {
-      // drain the first few rows if offset is larger than zero
-      while (inputIndex < offset) {
-        if (inputIterator.hasNext) inputIterator.next()
-        inputIndex += 1
+      if (ignoreNulls) {
+        findNextRowWithNonNullInput()
+      } else {
+        // drain the first few rows if offset is larger than zero
+        while (inputIndex < offset) {
+          if (inputIterator.hasNext) inputIterator.next()
+          inputIndex += 1
+        }
+        inputIndex = offset
       }
-      inputIndex = offset

Review Comment:
   Thank you, I considered this but unfortunately it does not work. The actual 
projection (or default value) is created in `doWrite` so `prepare` needs to 
initialize variables such as `input`, `inputIndex` etc.



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

To unsubscribe, e-mail: [email protected]

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