HeartSaVioR opened a new pull request, #60665:
URL: https://github.com/apache/spark/pull/60665

   ### What changes were proposed in this pull request?
   
   When the watermark is on an equality key, state format V4 reads that key as 
the row's event
   time and indexes the row by it. This PR handles a NULL key: it has no event 
time, and the row
   gets no index entry, so it is never evicted by time. V2 and V3 already keep 
such rows, because
   their key eviction predicate is unknown for NULL.
   
   ### Why are the changes needed?
   
   V4 fails the query when the key is a NULL window:
   
   ```scala
   val left = leftDf.withWatermark("lt", "10 seconds")
     .select($"lk", window($"lt", "10 seconds").as("lw"))
   val right = rightDf.select($"rk", when($"s" >= 0, struct(...)).as("rw"))  // 
no watermark
   left.join(right, expr("lk = rk AND lw = rw"), "full_outer")
   ```
   
   A right row with a NULL `rw` throws `NullPointerException` in
   `SymmetricHashJoinStateManagerV4.append`. For a NULL timestamp key, V4 reads 
time 0, so it
   evicts the row at the first eviction and a full outer join emits it at once, 
unlike V2 and V3.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, for state format V4 only (internal, off by default): the NPE is gone, 
and a row with a
   NULL watermarked key stays in state as in V2 and V3. No state layout change.
   
   ### How was this patch tested?
   
   New test in `StreamingFullOuterJoinBase` for window and timestamp keys; it 
runs on V2, V3 and
   V4. On master it passes on V2 and V3 and fails on V4.
   
   In scope: NULL handling of the V4 event-time key. Out of scope: NULL 
value-side event times,
   and emitting NULL-key rows of outer joins (SPARK-61382, all versions).
   
   ### Note for reviewers, including AI review
   
   Please review only the changes in this PR. For each finding, please 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]

Reply via email to