HeartSaVioR commented on code in PR #60284:
URL: https://github.com/apache/spark/pull/60284#discussion_r4528825145
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +297,22 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
return None
}
+ // State eviction compares this cutoff in timestamp units against the
constrained column.
+ val hasTimestampStateAttribute = constraintTerm.exists {
+ case a: AttributeReference =>
+ attributesToFindStateWatermarkFor.contains(a) && a.dataType ==
TimestampType
+ case _ => false
+ }
+ if (!hasTimestampStateAttribute) return None
+
+ // A bound must advance with the opposite watermark. The occurrence check
above limits
+ // each input to one attribute, so there can be at most one opposite
watermark term.
+ val watermarkTerms =
terms.filter(_.references.exists(attributesWithEventWatermark.contains))
+ if (watermarkTerms.isEmpty ||
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.
Confirmed at this commit: with your query, the left row is emitted with
nulls in the first batch, and the later match is lost (reproduced on state
formats 2 to 4). The cause is the negative watermark term, which already evicts
too early on master when the query has no constant conjunct. SPARK-61350
(#60286), the next PR in this stack, rejects such terms, and your query fails
analysis there; a test in #60286 pins this
([3a696a71dd6](https://github.com/apache/spark/pull/60286/commits/3a696a71dd6416df4d2631f438032af0cb2f3196)).
The other forms you list, integral casts in `>=`/`<=` bounds and whole days
in daylight-saving zones, are inexact in the range solver with or without a
constant conjunct. For a column without its own watermark, SPARK-61347 (#60282)
now derives no cutoff from them
([4000ae8f0c6](https://github.com/apache/spark/pull/60282/commits/4000ae8f0c6012cd60655a093ed642ce08e68651));
the general solver fix is a known follow-up (SPARK-61381). A constant conjunct
never made them safe: it only stopped eviction entirely, which is what this PR
removes, so we will not keep it as a cap.
<!-- sp2k-review1 reply 4523590739 -->
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +297,22 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
return None
}
+ // State eviction compares this cutoff in timestamp units against the
constrained column.
+ val hasTimestampStateAttribute = constraintTerm.exists {
+ case a: AttributeReference =>
+ attributesToFindStateWatermarkFor.contains(a) && a.dataType ==
TimestampType
+ case _ => false
+ }
+ if (!hasTimestampStateAttribute) return None
+
+ // A bound must advance with the opposite watermark. The occurrence check
above limits
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, the comment said more than this commit checks. It now states what
the code requires: a term on the opposite input's watermarked event time
([3efe52a82f2](https://github.com/apache/spark/pull/60284/commits/3efe52a82f261a9f9e52638a9ecdb71fb70e5737)).
The sign check is SPARK-61350 (#60286), the next commit, which has its own
comment, so I did not add a TODO here.
<!-- sp2k-review1 reply 4523590747 -->
##########
docs/streaming/apis-on-dataframes-and-datasets.md:
##########
@@ -1435,6 +1444,11 @@ Additional details on supported joins:
- Joins can be cascaded, that is, you can do `df1.join(df2, ...).join(df3,
...).join(df4, ....)`.
+- For stream-stream outer and semi joins, the time constraint that finalizes
an input's rows must
+ bound a timestamp column of that input by the other input's event time,
through an equality key
+ or a range condition. A bound that uses only constants, such as `leftTime >
10`, or a numeric
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, fixed: the example now reads `CAST(leftTime AS BIGINT) > 10`, which
analyzes and still uses only constants
([3efe52a82f2](https://github.com/apache/spark/pull/60284/commits/3efe52a82f261a9f9e52638a9ecdb71fb70e5737)).
<!-- sp2k-review1 reply 4523590753 -->
--
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]