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

   ### What changes were proposed in this pull request?
   
   A stream-stream left semi join now stores every right input row, including a 
row whose event time is at or below the batch's eviction cutoff. The eviction 
at the end of the batch still removes such a row. Inner and outer joins keep 
skipping it, because they process the left input first.
   
   ### Why are the changes needed?
   
   Since SPARK-55973, a left semi join processes the right input of a 
micro-batch before the left input. The join did not store a right row that the 
batch evicts, because it assumed that the batch's left rows had already probed 
it. For a left semi join they have not. With the default 
`spark.sql.streaming.statefulOperator.allowMultiple=true`, late filtering uses 
the previous batch's watermark and eviction uses the current one, so a right 
row between the two passes late filtering but was not stored. A left row of the 
same batch then found no match and was never emitted.
   
   For example, take `leftKey = rightKey AND leftTime = rightTime` with 
0-second watermarks on both inputs. A batch with late-events watermark 100 s 
and eviction watermark 105 s receives left (1, 102) and right (1, 102). It 
should emit (1, 102), but emits nothing.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. A left semi join now emits a left row whose matching right row arrives 
in the same micro-batch with event times between the late-events watermark and 
the eviction watermark. In Spark 4.2.0 to 4.3.0 that row was dropped. Such 
right rows are now written to state and removed in the same batch, so the 
number of updated state rows of a left semi join can grow.
   
   ### How was this patch tested?
   
   Added two tests to `StreamingLeftSemiJoinBase`: equal event times, and a key 
shifted by 10 seconds while the watermark advances by 50 seconds. Each checks 
the output and that the state rows are removed at the end of the batch. They 
run in state format 2 (RocksDB and HDFS), 3 and 4 (with and without changelog 
checkpointing).
   
   ```sh
   build/sbt 'sql/testOnly *StreamingLeftSemiJoinV4Suite 
*StreamingLeftSemiJoinWithVCFSuite *StreamingLeftSemiJoinWithoutVCFSuite'  # 
100 tests, 0 failures
   ```
   
   Scalastyle for sql, main and test sources: 0 errors, 0 warnings.
   
   Without the fix, all 12 runs of the new tests fail: the join emits no row in 
the third batch.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Anthropic 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