HeartSaVioR commented on PR #60279:
URL: https://github.com/apache/spark/pull/60279#issuecomment-6775614175

   > [!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 for the 
[review](https://github.com/apache/spark/pull/60279#pullrequestreview-5842222407).
 Answers to the items in its summary.
   
   - **Checkpoint check rejects time-range joins that this change leaves 
unchanged.** Agreed, fixed in 
[4fd804c5931](https://github.com/apache/spark/pull/60279/commits/4fd804c59319e26930682a4838f73f995b148c23).
 The restart check now also accepts two-sided time-interval joins on the 
inputs' own event times, such as the guide's impressions-and-clicks join. Every 
ordering conjunct must compare the two event times, each shifted only by exact 
constant intervals; no equality key may use an event time; and both event times 
must get a range bound. For that shape the old and new code solve the same 
conjuncts for the same columns, so the saved state, scan starts, V4 index and 
output watermark are identical. A local test that resumed checkpoints written 
by the base branch, in V2 to V4, confirmed it, as do the bundled Spark 2.4.0 
and 3.5.1 checkpoints, which resume again; the SPARK-26187 and SPARK-48687 
tests read them again.
     - We use this syntactic rule rather than a comparison of the old and new 
derivations. The base solver also took bounds that this stack drops 
(constant-only conjuncts, numeric columns, negative watermark terms), so a 
comparison through today's solver could call two derivations equal when the 
base evicted differently. Keeping the base solver only for the comparison would 
keep a second copy of the code this stack fixes.
     - `leftTime = rightTime` with a watermark only on the left keeps the base 
derivation in this PR alone, but stays rejected. That derivation is the bug 
that SPARK-61345 (#60280), the next PR in the same release, fixes: right rows 
are not filtered as late, so a right row can still match a left row that the 
base already evicted. SPARK-61345 changes the eviction and output watermark for 
exactly this shape and raises the checkpoint version, so the release must 
reject these checkpoints anyway.
   - **Outer joins bounded only through a cast non-TIMESTAMP column.** 
Confirmed: with `rightTime <= CAST(expiry AS TIMESTAMP)` and a BIGINT `expiry`, 
this PR never emits the unmatched left row and keeps it in state, while 
analysis still admits the query (reproduced on state formats 2 and 4, also with 
`BETWEEN leftTime AND CAST(expiry AS TIMESTAMP)`). Master is wrong for this 
shape too: it applies the cutoff solved for `expiry` to `leftTime`, so it emits 
the left rows with nulls at watermark 400 s although `expiry` is 700 s, and 
then loses the match from a right row at 460 s. Keeping master's eviction here 
would therefore bring back wrong output. SPARK-61348 (#60283), in this same 
stack, rejects this shape at analysis, and all seven PRs target 4.4.0 together, 
so no release ships this PR without it. Moving the TIMESTAMP rule into this PR 
would leave SPARK-61348 with almost no change of its own, so we are keeping the 
split.
   - **The version only validates and never selects the base behavior.** This 
is deliberate: the base derivation drops matches and emits null rows too early, 
so we do not offer a way to run it. Joins whose derivation does not change now 
resume (above). SPARK-61345 (#60280) adds the internal conf 
`spark.sql.streaming.join.checkFinalization.enabled` 
([c4bdbf09fdb](https://github.com/apache/spark/pull/60280/commits/c4bdbf09fdbea72fee5ab22ad03b839f1d9d7a37)):
 it turns the stack's new outer and semi admission failures into warnings, 
while eviction stays corrected.
   - **No flag restores the base eviction column or output watermark.** Same 
answer as above. The migration guide now says that the corrected eviction 
cannot be turned off, and that this is why these corrections are made only in 
4.4.0.
   - **Restarting from an older checkpoint now fails.** Narrowed: time-interval 
joins on the inputs' own event times, including the bundled 2.4.0 and 3.5.1 
checkpoints, now resume 
([4fd804c5931](https://github.com/apache/spark/pull/60279/commits/4fd804c59319e26930682a4838f73f995b148c23)).
 Joins whose eviction or output watermark changes are still rejected.
   - **Existing checkpoints of all join types go through the new restart 
check.** Yes; with 
[4fd804c5931](https://github.com/apache/spark/pull/60279/commits/4fd804c59319e26930682a4838f73f995b148c23)
 the check accepts every shape whose saved rows keep their meaning, as 
described above.
   - **New writer, old reader.** True, a downgrade is not detected. An older 
Spark ignores offset-log keys it does not know, and the only check older 
versions enforce is the offset or commit log format version. Raising that would 
block a downgrade of every streaming query, not only of joins. We keep the 
migration guide's warning against using a checkpoint written by the new version 
with an older one. For the shapes that resume, the saved rows mean the same in 
both versions, so a downgrade of those joins reads state that means the same in 
both versions.
   - **The output watermark held at 0.** Narrowed in 
[4fd804c5931](https://github.com/apache/spark/pull/60279/commits/4fd804c59319e26930682a4838f73f995b148c23):
 the join holds back its output watermark only for an input whose event time 
reaches the next stateful operator, found by following that operator's 
event-time column down to the join. When the plan between them has a shape we 
do not recognize, for example a union, the join still holds back for both 
inputs.
   - **Downstream operators keep more state and may never emit.** With 
[4fd804c5931](https://github.com/apache/spark/pull/60279/commits/4fd804c59319e26930682a4838f73f995b148c23),
 a pipeline that aggregates the bounded input's event time, such as a window 
over `impressionTime` after `clickTime <= impressionTime + INTERVAL 1 HOUR`, 
emits as before. Where the stall is required, SPARK-61345 (#60280, 
[c4bdbf09fdb](https://github.com/apache/spark/pull/60280/commits/c4bdbf09fdbea72fee5ab22ad03b839f1d9d7a37))
 names its cause in the admission error, the join support table and the 
migration guide.
   - **Nothing reports the held watermark.** The fix above removes the stall 
where it was not needed, and the docs and the admission error name the cause 
where it is. We did not add a progress metric in this stack; a metric for the 
join's output watermark would be a useful follow-up.
   - **Downstream state grows behind a held watermark.** Same as above: it now 
happens only when the downstream operator uses the event time of an input 
without a bound.
   - **The TIMESTAMP-only cutoff and the analysis check.** See the cast-column 
item above: SPARK-61348 (#60283) makes the analysis check use the same 
TIMESTAMP-only rule.
   - **Blast radius.** The analysis-check part is answered by the cast-column 
item above. The read-only state data source does not need the indexed-column 
ordinal: it only iterates over all rows of the state and never evicts, and the 
stored rows do not depend on the ordinal.
   - **A side bounded only by a non-TIMESTAMP column.** Outer and semi joins of 
this shape fail analysis from SPARK-61348 (#60283) on; inner joins keep that 
side's rows, which is correct, because the base evicted them by the wrong 
column.
   - **Only TIMESTAMP columns receive a cutoff.** As above. The reserved V4 
slots are at the bottom of the timestamp range: only an event time in the first 
millisecond of ISO year -290308 could share them.
   - **State growth.** This is the cost of not evicting rows that can still 
match: a join bounded on another TIMESTAMP column keeps a row until that column 
passes. A side bounded only through a non-TIMESTAMP column makes outer and semi 
joins fail analysis from SPARK-61348 (#60283) on, and growth behind a held 
watermark is narrowed by 
[4fd804c5931](https://github.com/apache/spark/pull/60279/commits/4fd804c59319e26930682a4838f73f995b148c23).
   - **Inner joins bounded only through a non-TIMESTAMP column.** They keep 
that side's state, because no TIMESTAMP bound exists; the base evicted it by 
the wrong column and could lose matches. Keeping the rows is the price of 
correct results.
   - **PR description.** Updated: the user-facing section now says that a 
downstream stateful operator that uses the event time of an input without an 
eviction bound may stop emitting, not only keep more state and finalize later.
   - **Decision challenge: silent downstream stall.** We kept the query running 
and made the requirement visible instead of adding a start-time error. With 
[4fd804c5931](https://github.com/apache/spark/pull/60279/commits/4fd804c59319e26930682a4838f73f995b148c23),
 the join holds back only for an input whose event time reaches the next 
stateful operator, so pipelines that use only a bounded input's event time no 
longer stall. Where the stall is required, SPARK-61345 (#60280, 
[c4bdbf09fdb](https://github.com/apache/spark/pull/60280/commits/c4bdbf09fdbea72fee5ab22ad03b839f1d9d7a37))
 names the watermark and time constraint that avoid it. A start-time error 
would also reject update-mode pipelines that emit correct results, and a 
precise check needs the same reachability rule, which works on the physical 
plan, after analysis.
   
   <!-- sp2k-review1 toplevel 60279 -->
   


-- 
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]

Reply via email to