HeartSaVioR commented on code in PR #60701:
URL: https://github.com/apache/spark/pull/60701#discussion_r4638748753
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/operators/stateful/join/SymmetricHashJoinStateManager.scala:
##########
@@ -277,7 +277,10 @@ class SymmetricHashJoinStateManagerV4(
case Some(idx) =>
val attr = inputValueAttributes(idx)
- if (attr.dataType.isInstanceOf[StructType]) {
+ // A NULL event time is read as time 0, as a NULL timestamp always was.
+ if (row.isNullAt(idx)) {
+ 0L
Review Comment:
> [!NOTE]
> **DISCLAIMER:** This comment was written by an LLM: Claude Opus 5.5
(`claude-opus-5-5`, 1M context), running as an SP2K agent on behalf of
@HeartSaVioR.
Reproduced, with a scratch suite on this PR's head: left `(lk, et, lt2)`
with the watermark on `et`, `lk = rk AND lt2 BETWEEN rt + INTERVAL 5 SECONDS
AND rt + INTERVAL 15 SECONDS`. A left row with a NULL window `et` and `lt2 =
100 s`, then a right row with `rt = 88 s`: V2 returns the match, V4 does not.
Two more cases on the same head show where this comes from:
- With a NULL TIMESTAMP `et` instead of a window, V4 loses the match the
same way. That is master's behavior, which this PR does not change: V4 reads a
NULL timestamp as 0. This PR makes a NULL window behave the same way.
- With a non-NULL window that ends at 10 s while the cutoff is 35 s, V2 and
V4 both lose the match on master.
The condition cannot bound a window struct, so a side whose watermark is on
a window outside the keys gets its cutoff only from another column, and master
evicts its rows by the event time with that column's cutoff. That is
[SPARK-61988](https://issues.apache.org/jira/browse/SPARK-61988) (#60667),
which evicts by the bounded column (`lt2` here) and fixes all three cases. So I
kept this PR's handling, which matches master's for a NULL timestamp, and left
the eviction column to
[SPARK-61988](https://issues.apache.org/jira/browse/SPARK-61988).
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/operators/stateful/join/SymmetricHashJoinStateManager.scala:
##########
@@ -277,7 +277,10 @@ class SymmetricHashJoinStateManagerV4(
case Some(idx) =>
val attr = inputValueAttributes(idx)
- if (attr.dataType.isInstanceOf[StructType]) {
+ // A NULL event time is read as time 0, as a NULL timestamp always was.
+ if (row.isNullAt(idx)) {
Review Comment:
> [!NOTE]
> **DISCLAIMER:** This comment was written by an LLM: Claude Opus 5.5
(`claude-opus-5-5`, 1M context), running as an SP2K agent on behalf of
@HeartSaVioR.
The NULL window as a join key is
[SPARK-61986](https://issues.apache.org/jira/browse/SPARK-61986), fixed by
#60704: a row whose watermarked join key is NULL can never match, so it is kept
out of the state and never reaches `extractEventTimeFnFromKey`. This PR covers
the value side only.
##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingJoinSuite.scala:
##########
@@ -1157,6 +1157,26 @@ abstract class StreamingInnerJoinBase extends
StreamingJoinSuite {
df1.join(df2, expr("leftKey <=> rightKey"))
.select("leftKey", "rightKey", "leftValue", "rightValue")
}
+
+ test("SPARK-62022: NULL window watermark column outside the join keys") {
+ val leftInput = MemoryStream[(Int, Int)]
+ val rightInput = MemoryStream[(Int, Int)]
+ val lt = timestamp_seconds($"t")
+ // The watermark is on a window struct that is NULL for a negative input.
+ 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")
+ // Output the whole lw, so that nested column pruning keeps the struct in
the join state.
Review Comment:
> [!NOTE]
> **DISCLAIMER:** This comment was written by an LLM: Claude Opus 5.5
(`claude-opus-5-5`, 1M context), running as an SP2K agent on behalf of
@HeartSaVioR.
Fixed: "Reference lw as a whole, so that nested column pruning keeps the
struct in the join state."
--
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]