HeartSaVioR commented on code in PR #60307:
URL: https://github.com/apache/spark/pull/60307#discussion_r4536366604
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/operators/stateful/join/StreamingSymmetricHashJoinExec.scala:
##########
@@ -910,6 +917,8 @@ case class StreamingSymmetricHashJoinExec(
!stateKeyWatermarkPredicateFunc(key) &&
!stateValueWatermarkPredicateFunc(thisRow)
isNotEvictingInThisBatch ||
+ // if the left input of this batch still has to probe the input
+ joinType == LeftSemi ||
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.
Agreed for cutoffs that are exact today, done in
[cba0be873c6](https://github.com/apache/spark/pull/60307/commits/cba0be873c611eafc14a3dd2e8a54608269aefaa).
On the right side of a left semi join, a row that the batch evicts is now
skipped when one of two cutoffs at the late-events watermark shows that no left
row passing late filtering can match it:
- **A key cutoff:** when the left input's late-filtered column is the left
join key at an ordinal, the right key at that ordinal is compared with the
late-events watermark.
- **A value cutoff on the right event time:** solved only from conjuncts
that compare it with that left column, each shifted only by literal intervals
without a day or month part, and with no cast.
Every other evicted right row is still stored, and the TODO at the check
keeps naming SPARK-61344 and SPARK-61381 for those conditions. The solver and
its other callers, eviction, the V4 offsets, inner and outer joins and the left
side are unchanged.
New tests in V2, V3 and V4 check:
- under `allowMultiple=false`, a minute-to-hour interval join reports the
same updated and removed state rows as the base branch;
- in the default mode, the same condition skips a right row below the exact
cutoff and still emits a same-batch match above it;
- `leftTime = rightTime` with only a left watermark skips a right row at or
below the late-events watermark and keeps its match;
- a bound with whole days still stores every evicted right row.
The four earlier same-batch tests pass unchanged, including the
`rightExpiry` and left-shifted key cases.
<!-- sp2k-review3 reply 4531790506 -->
##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingJoinSuite.scala:
##########
@@ -2425,6 +2425,82 @@ abstract class StreamingLeftSemiJoinBase extends
StreamingJoinSuite {
}
}
+ // A left semi join processes the right input before the left input. A right
row at or below
+ // its eviction cutoff passes late filtering when it is above the
late-events watermark, and
+ // the left rows of the same batch must still find it. Each case runs a
batch whose
+ // late-events watermark is 100 seconds and whose eviction watermark is
`watermark` seconds.
+ // (name, condition, left time, right time, watermark, state rows after the
second batch and
+ // after the third)
+ for ((name, condition, leftTime, rightTime, watermark, rowsBefore,
rowsAfter) <- Seq(
+ ("equal event times", "leftTime = rightTime", 102, 102, 105, 2L, 0L),
+ // The left key leftTime + 10 seconds of (7, 100) stays above the
100-second cutoff.
+ ("a key shifted by less than the watermark step",
+ "leftTime + INTERVAL 10 SECONDS = rightTime", 120, 130, 150, 3L, 1L),
+ // A value cutoff of the watermark less 10 seconds: (1, 130) is at or
below 140 seconds.
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 in
[cba0be873c6](https://github.com/apache/spark/pull/60307/commits/cba0be873c611eafc14a3dd2e8a54608269aefaa),
with your wording: the right cutoff is 139.999 s.
<!-- sp2k-review3 reply 4531790520 -->
--
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]