HeartSaVioR opened a new pull request, #60701:
URL: https://github.com/apache/spark/pull/60701
### What changes were proposed in this pull request?
State format V4 indexes each stored row of a stream-stream join by its event
time. When the
watermark is on a window struct column that is not a join key, V4 reads that
time from the
struct's `end` field, and throws `NullPointerException` when the struct is
NULL. This PR reads a
NULL event time as time 0, as V4 already does for a NULL timestamp column.
### Why are the changes needed?
The query fails on V4, while V2 and V3 return the right rows. For example,
with
`spark.sql.streaming.join.stateFormatVersion=4`:
```scala
val lt = timestamp_seconds($"t")
val left = leftInput.toDF().toDF("lk", "t")
.select($"lk", $"t", when($"t" >= 0,
struct(lt.as("start"), (lt + expr("INTERVAL 10
SECONDS")).as("end"))).as("lw"))
.withWatermark("lw", "10 seconds")
val right = rightInput.toDF().toDF("rk", "s")
left.join(right, expr("lk = rk")).select($"lk", $"t", $"lw".isNull, $"s")
// left rows (1, -1) and (1, 5), then right row (1, 7)
```
- Before: the query fails with `NullPointerException` in
`SymmetricHashJoinStateManagerV4.extractEventTimeFn` when it stores the
left row `(1, -1)`.
- After: `(1, -1, true, 7)` and `(1, 5, false, 7)`, as on V2 and V3.
### Does this PR introduce _any_ user-facing change?
Yes, for state format V4 only (internal, off by default): the query no
longer fails. No state
layout change.
### How was this patch tested?
New test in `StreamingInnerJoinBase`, so it runs on V2, V3 and V4.
Without the fix, it fails on V4 with the `NullPointerException` and passes
on V2 and V3.
Out of scope: when such a row is evicted. V4 files it at time 0, as it does
for a NULL
timestamp column, and V2 and V3 never evict it.
Note on merging with #60665 (SPARK-61986): that PR adds a TODO naming
SPARK-62022 right above
the line this PR changes. Whichever of the two lands second gets a small
textual conflict there,
and should drop the TODO.
### Note for reviewers, including AI review
Please review only this PR's own commit(s). For each finding, give a
runnable reproducer and
say whether master has the same behavior.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.
--
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]