HeartSaVioR commented on code in PR #60282:
URL: https://github.com/apache/spark/pull/60282#discussion_r4604924679
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +878,23 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
return None
}
+ // The terms count a whole day as 24 hours, although Spark adds days in
the session time
+ // zone, where a day can be 23 or 25 hours, and read CAST(ts AS BIGINT) as
ts, although the
+ // cast drops the fraction of a second. Either can put the cutoff above a
row that can still
+ // match. A column with its own watermark keeps such a cutoff, as existing
queries rely on
+ // it. With exactForUnwatermarkedColumns, any other column, such as the
bounded column of an
+ // input without a watermark, gets no cutoff from such a condition.
+ val stateColumnHasWatermark = constraintTerm.exists {
+ case a: AttributeReference =>
+ attributesToFindStateWatermarkFor.contains(a) &&
a.metadata.contains(delayKey)
+ case _ => false
+ }
+ if (exactForUnwatermarkedColumns && !stateColumnHasWatermark &&
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, reproduced and fixed in
[1a06df8f3d5](https://github.com/apache/spark/pull/60282/commits/1a06df8f3d5fd087e6762e5ef41de7aba14c853f).
With a watermark only on the right input, `lk = rk AND CAST(lt AS
DOUBLE) + CAST(rt AS DOUBLE) > 100` gave `lt` a cutoff, and an inner join
lost the match of a left
row at 40 seconds with a right row at 61 seconds in every state format. The
solver now gives a
column without its own watermark no cutoff when the opposite watermark term
has the column's sign,
next to the inexact-arithmetic rule, so state eviction, the admission check
and its notes skip such
a bound, and the left outer form fails analysis with the existing error and
no inexact-bound note.
The rule of earlier versions, which applies with the finalization check
disabled, still reads it.
A TODO names SPARK-61350 for columns with their own watermark. Tests: a
solver test for both signs
and a one-sided end-to-end test in formats 2 to 4; the existing one-sided
range tests keep their
cutoffs. Without the gate, the solver test and the end-to-end tests fail.
<!-- sp2k-review11 reply 4598419925 -->
##########
docs/streaming/apis-on-dataframes-and-datasets.md:
##########
@@ -1297,6 +1297,17 @@ joined <- join(
Outer joins have the same guarantees as [inner
joins](#semantic-guarantees-of-stream-stream-inner-joins-with-watermarking)
regarding watermark delays and whether data will be dropped or not.
+Unmatched output and state removal use the same cutoff, derived from the
opposite input's
+watermark and the time constraint. In the example above, the `clickTime`
watermark finalizes
+impressions; no watermark on `impressionTime` is needed for this. Without that
watermark, the
+time constraint must have an exact length. An interval of a day or more, such
as
+`INTERVAL 1 DAY` or `INTERVAL 48 HOURS`, does not finalize impressions in any
session time zone,
+because Spark adds its whole days in the session time zone, where a day can
last 23 or 25 hours.
+Nor does a truncating cast such as `CAST(impressionTime AS BIGINT)`. An outer
join that relies
+on such a bound fails analysis; add a watermark on `impressionTime`, or use a
bound shorter than
Review Comment:
> [!NOTE]
> **DISCLAIMER:** This comment was written by an LLM: Claude Sonnet 5.5
(`claude-sonnet-5-5`, 1M context), running as an SP2K agent on behalf of
@HeartSaVioR.
Fixed in
[1a06df8f3d5](https://github.com/apache/spark/pull/60282/commits/1a06df8f3d5fd087e6762e5ef41de7aba14c853f).
The join guide, the migration guide and the analysis error's note now
recommend an exact bound, such as a bound shorter than a day on the TIMESTAMP
columns in place of the cast, and say that a watermark on that input lets the
join run but counts a day as 24 hours and reads the cast as exact. The analysis
error tests check the new advice for the one-day, 48-hour and cast shapes, and
fail if the note recommends an inexact bound again.
<!-- sp2k-review11 reply 4598420018 -->
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +878,23 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
return None
}
+ // The terms count a whole day as 24 hours, although Spark adds days in
the session time
Review Comment:
> [!NOTE]
> **DISCLAIMER:** This comment was written by an LLM: Claude Sonnet 5.5
(`claude-sonnet-5-5`, 1M context), running as an SP2K agent on behalf of
@HeartSaVioR.
Added in
[1a06df8f3d5](https://github.com/apache/spark/pull/60282/commits/1a06df8f3d5fd087e6762e5ef41de7aba14c853f).
`TODO(SPARK-61381)` now sits at the exactness gate, at `hasInexactArithmetic`
and at the exact-shift filter of `getEventTimeWatermarkFromKey`. Each says what
stays until then: an inner join on `rightTime <= expiry + INTERVAL 1 DAY`, with
`expiry` lacking a watermark, keeps every left row, its outer and left semi
forms fail analysis, and a join on `leftTime = rightTime + INTERVAL 1 DAY`
holds the output watermark at 0 for the right input.
<!-- sp2k-review11 reply 4598420028 -->
--
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]