vitaliili-db commented on code in PR #43236:
URL: https://github.com/apache/spark/pull/43236#discussion_r1355356343
##########
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:
yes, it works when `ignoreNulls == true` but breaks when `ignoreNulls ==
false`
In particular it will trigger last `else` branch in `doWrite`:
```
else {
(current: InternalRow) =>
if (inputIndex >= 0 && inputIndex < input.length) {
val r = WindowFunctionFrame.getNextOrNull(inputIterator)
projection(r)
} else {
// Use default values since the offset row does not exist.
fillDefaultValue(current)
}
inputIndex += 1
}
```
--
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]