HeartSaVioR commented on code in PR #60664:
URL: https://github.com/apache/spark/pull/60664#discussion_r4621563714
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +186,15 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
return None
}
+ // The cutoff must rise with the watermark: `watermark + c < leftTime`.
Without the watermark
+ // term, or with `-watermark`, later rightTime values can still match old
leftTime values.
+ val watermarkTerms = terms.filter(_.references.exists { a =>
+ attributesWithEventWatermark.contains(a) && a.metadata.contains(delayKey)
+ })
+ if (watermarkTerms.size != 1 ||
watermarkTerms.head.isInstanceOf[UnaryMinus]) {
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.
Thanks, I reproduced it. With `le = lt + INTERVAL 100 SECONDS` and `leftKey
= rightKey AND le > rt - INTERVAL 5 SECONDS AND CAST(lt AS LONG) > 10`, this PR
alone emits `(1, 20, 120, null)` in batch 3 and then loses `(1, 20, 120, 50)`,
on V2, V3 and V4. Master passes this case only because the constant caps the
cutoff at 10 s; without the constant conjunct, master fails the same way.
So the cause is on master: the cutoff is solved for `le` but applied to
`lt`. That is [SPARK-61988](https://issues.apache.org/jira/browse/SPARK-61988),
which #60667 fixes by evicting by the column the condition bounds. This PR is
now stacked on #60667, so it cannot land without that fix and uncover the bug.
##########
docs/streaming/ss-migration-guide.md:
##########
@@ -25,6 +25,13 @@ Please refer [Migration Guide: SQL, Datasets and
DataFrame](../sql-migration-gui
## Upgrading from Structured Streaming 4.3 to 4.4
+- Since Spark 4.4, a range condition of a stream-stream join bounds the state
of one input only
+ if the other input's watermarked column appears in it with a positive sign,
for example
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.
Thanks, agreed. The new commit rewrites the entry. It now says the condition
must be one that can be rearranged to `leftTime > rightTime + c` (or `>=`), and
it gives each form its own reason: `CAST(leftTime AS LONG) > 10` no longer
holds back the cutoff of other range conditions, and `CAST(leftTime AS LONG) +
CAST(rightTime AS LONG) > 100` no longer evicts rows that later rows can still
match. The analysis sentence now says "without a watermark in the join keys". I
fixed the same wording in the solver comment and in the three test comments you
listed.
--
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]