HeartSaVioR commented on PR #60283: URL: https://github.com/apache/spark/pull/60283#issuecomment-6792708693
> [!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 [re-review](https://github.com/apache/spark/pull/60283#pullrequestreview-5849494176). Answers to the items in its summary; the inline comments are answered in their threads. - **Guides on inner joins (P2).** Added in [6ffda93fc12](https://github.com/apache/spark/pull/60283/commits/6ffda93fc129cb081ffc13de754e9222e664d92b). - The join guide now says that an inner join cleans up an input's state only with a qualifying time constraint. Its example is an inner join whose only bound compares 10-second left windows with 20-second right windows: the join keeps every left row and holds back its output watermark for the left input, so a stateful operator after the join that uses the left windows cannot emit results. - The Spark 4.4 migration guide has a matching entry. Such inner joins no longer remove those rows; earlier versions removed them by window end, which could lose matches. Windows that last at least as long as the other input's are still removed. - **Spec: whole-window comparisons yield no cutoff for any window lengths.** Replaced by the fix in the existing thread ([6ffda93fc12](https://github.com/apache/spark/pull/60283/commits/6ffda93fc129cb081ffc13de754e9222e664d92b)). `window()` now records each window's duration in the column metadata, and a whole-window comparison such as `lw > rw` gets a cutoff again when the stored windows last at least as long as the other input's windows, which covers every case the base branch handled correctly. Stored windows that are shorter still get none. - **Spec: no setting restores the base behavior.** The fix restores it, with no setting needed, wherever the base behavior was correct. Where it was wrong, for stored windows shorter than the other input's, nothing restores it on purpose, because it dropped matches. Such an outer or left semi join still runs when `spark.sql.streaming.join.checkFinalization.enabled` is `false`, with a warning; it then keeps that input's state and never outputs its unmatched rows, as the conf documents. - **Spec: outer and semi joins bounded only through a time-window column fail analysis.** This now applies only when the stored windows are shorter than the other input's. Range bounds on numeric, DATE and TIMESTAMP_NTZ columns still fail analysis, and the error and both guides state the window rule. - **Spec: inner joins bounded only by a whole-window comparison no longer evict that input.** This now applies only to stored windows shorter than the other input's, and the migration guide says so. - **Spec: interactions with existing settings.** Every join state format version and both multiple-stateful-operator modes apply the same rule, and the checkpoint watermark-semantics version stays at 4. Compared with earlier releases, the join evicts the same windows or fewer, so existing state stays valid. The state schema check ignores field metadata, so the new duration key does not affect existing checkpoints. - **Spec: a struct-typed bounded column never yields a range cutoff.** A column built by `window()` now yields one when its windows last at least as long as the other input's. Session windows and other struct columns still yield none, and equality keys on time windows are unchanged. - **Spec: the inner-join change has no flag and no migration note.** The migration guide now has the inner-join entry above. The change still has no flag, because restoring window-end eviction for stored windows shorter than the other input's would drop matches again. - **Spec: such an inner join keeps all of that input's rows.** This now applies only to stored windows shorter than the other input's, where keeping the rows is the price of correct matches; both guides say so. - **Spec: the output watermark stays at 0 for that input, so an append-mode aggregation over its window stops emitting.** This now applies only to stored windows shorter than the other input's. Such an aggregation no longer runs silently: from SPARK-61345 (#60280, [9c618562e01](https://github.com/apache/spark/pull/60280/commits/9c618562e0186b65f8fd2cae49f1c34bd7fb802c)) on, the query fails when it starts, with `STREAMING_JOIN_UNBOUNDED_DOWNSTREAM_EVENT_TIME`, which names the input and the missing time constraint. - **Verification.** The test with 10-second tumbling windows on both inputs now expects left outer, left semi and right outer joins to pass analysis and to finalize those windows, and a new test rejects stored windows shorter than the other input's ([6ffda93fc12](https://github.com/apache/spark/pull/60283/commits/6ffda93fc129cb081ffc13de754e9222e664d92b)). - **Decision challenge: left semi joins with only a numeric, DATE or TIMESTAMP_NTZ range bound fail analysis by default.** We keep the rejection, as you recommend: such a bound never finalizes the left state, like a left semi join without a time constraint, which the check already rejects. Setting `spark.sql.streaming.join.checkFinalization.enabled` to `false` runs such a join as before, with a warning. That conf now keeps the admission rule of earlier versions as the floor at every layer of this stack ([9c618562e01](https://github.com/apache/spark/pull/60280/commits/9c618562e0186b65f8fd2cae49f1c34bd7fb802c), [6ffda93fc12](https://github.com/apache/spark/pull/60283/commits/6ffda93fc129cb081ffc13de754e9222e664d92b)): for that floor the solver skips this PR's TIMESTAMP-column rule, so a join that earlier versions admitted runs, while one they rejected, such as an outer join without any watermark, still fails. A new test runs a left outer join on `n > CAST(rt AS BIGINT)` with the che ck disabled. - **PR description.** Updated. The runtime-change sentence now says that an inner join whose only bound on an input compares that input's time windows with longer windows of the other input keeps that input's rows and holds back the join's output watermark for that input, so a stateful operator after the join that uses those windows cannot emit results. Whole-window comparisons whose stored windows last at least as long as the other input's evict as before. <!-- sp2k-review2 toplevel 60283 --> -- 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]
