HeartSaVioR commented on code in PR #60664:
URL: https://github.com/apache/spark/pull/60664#discussion_r4640669169
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +209,16 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
return None
}
+ // The cutoff must rise with the watermark: `watermark + c < leftTime`.
Without the watermark
+ // term, the cutoff never rises and caps the other conjuncts' cutoffs.
With `-watermark`, the
+ // cutoff falls, and 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.
Fixed: on the whole-input path, where a cutoff solved for another column
applies to the event time, the solver keeps master's minimum again,
constant-only and negative-sign conjuncts included. That covers the legacy mode
and the default-mode fallback, and the V4 previous bound and the state
watermark use the same choice. The sum example still gets no cutoff, because
the rule applies only where the new rule gives a cutoff. New tests cover your
NTZ and legacy-mode examples.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +209,16 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
return None
}
+ // The cutoff must rise with the watermark: `watermark + c < leftTime`.
Without the watermark
+ // term, the cutoff never rises and caps the other conjuncts' cutoffs.
With `-watermark`, the
+ // cutoff falls, and 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.
Fixed: when a cutoff that rises with the watermark goes through a truncating
cast, such as `CAST(lt AS LONG)` on a TIMESTAMP, the solver keeps master's
minimum again, constant-only conjuncts included. Your example now keeps `(1,
14.2)` until `(1, 14.2, 19.6)` is emitted, and a new test covers it for state
formats 2 to 4. The sum example still gets no cutoff.
[SPARK-61381](https://issues.apache.org/jira/browse/SPARK-61381) stays open to
make such cutoffs exact.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -66,13 +66,17 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
* @param attributesWithEventWatermark attributes of the other side which
has a watermark column
* @param joinCondition join condition
* @param eventWatermark watermark defined on the input event
data
+ * @param risingCutoffsOnly whether only conjuncts whose cutoff
rises with the
+ * watermark give a cutoff. Earlier
versions also took
+ * constant-only and negative-sign
conjuncts.
* @return state value watermark in milliseconds, is possible.
*/
def getStateValueWatermark(
attributesToFindStateWatermarkFor: AttributeSet,
attributesWithEventWatermark: AttributeSet,
joinCondition: Option[Expression],
- eventWatermark: Option[Long]): Option[Long] = {
+ eventWatermark: Option[Long],
+ risingCutoffsOnly: Boolean = true): Option[Long] = {
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.
Inputs on the whole-input path now report master's state watermark again. An
input that the rule leaves without a cutoff is rejected when a stateful
operator follows the join, by the
[SPARK-62001](https://issues.apache.org/jira/browse/SPARK-62001) guard (#60713)
that #60667 now includes.
--
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]