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

   ### What changes were proposed in this pull request?
   
   A stream-stream join turns each range conjunct into a state cutoff by 
putting the other input's
   watermark into it. This PR uses a conjunct only when it has the form
   `watermark + c < stateTime` after canonicalization: the other input's 
watermarked column must
   appear in it once, with a positive sign. A conjunct without that column, or 
with it negated,
   gives no cutoff. The analysis check for outer and semi joins uses the same 
solver, so a join
   whose only range condition has such a form now fails analysis.
   
   ### Why are the changes needed?
   
   Such conjuncts do not bound the state. Example (inner join, 1 second 
watermarks):
   
   ```sql
   leftKey = rightKey AND CAST(lt AS LONG) + CAST(rt AS LONG) > 100
   ```
   
   Master evicts left `(1, lt=5)` once the watermark passes, then loses the 
match with a later
   right row `(1, rt=100)`. Similarly, in a left outer join with
   `lt > rt - INTERVAL 5 SECONDS AND CAST(lt AS LONG) > 10`, the constant 
conjunct caps the cutoff
   at 10 s, so left `(1, lt=20)` is never emitted as `(1, 20, null)`.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. The two queries above return the correct rows. Outer and semi joins 
whose only range
   condition is constant-only or has a negative watermark term fail analysis. 
They could not
   produce correct results before. The migration guide notes it.
   
   ### How was this patch tested?
   
   New `StreamingJoinRangeCutoffSuite` (both examples, state format V2-V4; both 
fail on master),
   plus new rows in `StreamingJoinHelperSuite` and `UnsupportedOperationsSuite`.
   
   In scope: the solver rule and the analysis result that follows from it.
   Out of scope: inexact bounds (SPARK-61381), which column the cutoff is 
applied to, and joins
   of an input without its own watermark.
   
   ### 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