spark-test commented on code in PR #60283:
URL: https://github.com/apache/spark/pull/60283#discussion_r4537867553
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +297,14 @@ 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
Review Comment:
Thanks, verified at 6ffda93fc12: `window()` now records each window's
length, and a whole-window comparison gets a cutoff again in both the analysis
check and eviction when the stored windows last at least as long as the other
input's. Outer and left semi joins bounded this way pass analysis again, and
inner joins evict those windows again, so this blocking issue is resolved. This
review raises one related problem: a union of window columns with different
lengths keeps only its first child's recorded length. The review's Decision
challenges section also asks whether stored windows shorter than the other
input's could take a cutoff lowered by the difference in lengths instead of
none.
<!-- SPARK_DEV_REVIEW_REPLY
{"feedback_id":"inline:4523339214","thread_id":"inline:4523339214","verdict_sha256":"bb1843920966852da76e64767a680cfca7fa7847933eecf5a8816bf3cf9580e3"}
-->
##########
docs/streaming/apis-on-dataframes-and-datasets.md:
##########
@@ -1433,8 +1451,31 @@ regarding watermark delays and whether data will be
dropped or not.
Additional details on supported joins:
+- For stream-stream outer and semi joins, an equality key counts as the time
constraint in the
+ table above when it is the other input's event time, or that event time
shifted by constant
+ intervals, such as `leftTime = rightTime + INTERVAL 10 MINUTES`. A key
shifted backward by whole
+ days, months or years, such as `leftTime = rightTime - INTERVAL 1 DAY`, or
truncated from the
+ other input's event time, such as `leftTime = CAST(CAST(rightTime AS BIGINT)
AS TIMESTAMP)`,
+ does not count. When both inputs have watermarks, a time range condition
between the two event
+ times, as in the time-interval join example above, can bound such a join
instead.
+
- 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 that input by the other input's event time, either through an equality
key on that event
+ time or its time window, or through a range condition on a timestamp column
of the input. A
+ range condition may also compare the input's time window as a whole with the
other input's,
+ such as `leftWindow > rightWindow`, when the input's windows last at least
as long as the
+ other input's. A range condition on a column of another type does not
qualify: a numeric
+ column, such as `n > CAST(rightTime AS BIGINT)`, a DATE or TIMESTAMP_NTZ
column, or a time
+ window shorter than the other input's.
+
+- A stream-stream inner join cleans up an input's state only with such a time
constraint. For
+ example, an inner join whose only time constraint is `leftWindow >
rightWindow`, with 10-second
+ left windows and 20-second right windows, keeps every left row in its state
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.
Review Comment:
**Nit (P3):** With the left input's state watermark held at 0, not every
stateful operator after the join stops emitting. An append-mode aggregation
over the left windows fails when the query starts, with
`STREAMING_JOIN_UNBOUNDED_DOWNSTREAM_EVENT_TIME`; operators that wait for the
watermark, such as event-time timeouts, never fire; and update-mode
aggregations and deduplication still emit rows. Readers may therefore avoid an
operator that works, and are not told that the append-mode case fails at start
rather than running without output. The matching bullet in
`docs/streaming/ss-migration-guide.md` (lines 76-77) has the same wording; the
equality-join bullet just below it there already describes these effects
precisely.
This extends an [existing
discussion](https://github.com/apache/spark/pull/60283#issuecomment-6792708693).
**Verification:**
- **Inspection:** Both inner-join window bullets describe the same
downstream effects as the migration guide's equality-join bullet and as the
start-time check and the held-back output watermark produce, and neither says
any longer that every stateful operator after the join cannot emit results.
##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingJoinNumericWatermarkSuite.scala:
##########
@@ -0,0 +1,330 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.streaming
+
+import org.apache.logging.log4j.Level
+
+import org.apache.spark.sql.{AnalysisException, DataFrame, Row}
+import org.apache.spark.sql.execution.streaming.runtime.MemoryStream
+import org.apache.spark.sql.execution.streaming.state.RocksDBStateStoreProvider
+import org.apache.spark.sql.functions._
+import org.apache.spark.sql.internal.SQLConf
+
+class StreamingJoinNumericWatermarkSuite extends StreamTest {
+ import testImplicits._
+
+ private val timestampRule = "A time range condition must bound a TIMESTAMP
column"
+
+ // Analysis rejects the plan before any state format is used. Each bound
below is exact, with
+ // no truncating cast and no whole days, so only the TIMESTAMP-column rule
rejects it.
+ test("left outer join cannot use a numeric state field for range eviction") {
+ val leftInput = MemoryStream[(Int, Long, Long)]
+ val rightInput = MemoryStream[(Int, Long)]
+ val left = leftInput.toDF().toDF("leftKey", "n", "time")
+ .select($"leftKey", $"n", timestamp_seconds($"time").as("lt"))
+ .withWatermark("lt", "1 second")
+ val right = rightInput.toDF().toDF("rightKey", "time")
+ .select($"rightKey", timestamp_seconds($"time").as("rt"))
+ .withWatermark("rt", "1 second")
+ val joined = left.join(right,
+ expr("leftKey = rightKey AND n > CAST(rt AS DOUBLE)"), "left_outer")
+ .select($"leftKey", $"n", $"lt")
+
+ val error = intercept[AnalysisException] {
+ testStream(joined)(
+ AddData(leftInput, (1, 20L, 20L)),
+ CheckNewAnswer())
+ }
+ assert(error.getMessage.contains("a watermark on the right input and a
time constraint"))
+ assert(error.getMessage.contains(timestampRule))
+ }
+
+ // Earlier versions admitted this join, so disabling the finalization check
runs it. The left
+ // state is never evicted, so the matched left row emits no null-padded row
later.
Review Comment:
**Nit (P3):** The only left row, (1, 20, 20), matches (1, 10), and an outer
join emits no null-padded row for a matched row whether that row is evicted or
kept, so this test still passes if the left state is evicted, for example if
eviction again applied the cutoff solved for `n` to `lt`, as the base branch
does. Only the warning assertion can fail, so the state behavior that the conf
doc and this comment describe is not checked; an unmatched left row that must
never be output, or a `numRowsTotal` assertion like the one in the inner-join
window test, would check it. The suite comment above the first test also says
each bound below is exact, with no truncating cast, but this test's `n >
CAST(rt AS BIGINT)` is a truncating cast, which the inexact-bound rule rejects
before the TIMESTAMP-column rule when the check is enabled.
**Verification:**
- **Regression:** With the finalization check disabled, a left outer join
bounded only by a numeric column keeps an unmatched left row in state after
both watermarks pass its time and never outputs it null-padded, and the test
fails when that row is evicted.
- **Inspection:** The comment about exact bounds applies only to tests whose
bounds have no truncating cast or whole days, and the disabled-check test's
comment names the assertion that observes retention.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -66,13 +301,23 @@ 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 exactForUnwatermarkedColumns whether a column without its own
watermark gets no
+ * cutoff from a condition that the
solver counts
+ * inexactly. State eviction and the
admission check set
+ * it, so they agree.
+ * @param baseAdmissionRules whether to skip the checks that
Spark 4.4 added to the
Review Comment:
**Nit (P3):** This flag skips only the TIMESTAMP and time-window column
check in `getStateWatermarkFromLessThenPredicate`. The other rule Spark 4.4
adds to this solver, the inexact-arithmetic check for columns without their own
watermark, is controlled by `exactForUnwatermarkedColumns` alone, so a call
that sets both flags still gets the 4.4 result: with `lt` not watermarked,
`CAST(lt AS BIGINT) >= CAST(rt AS BIGINT) + 5` gives no cutoff, while earlier
versions give one. The admission fallback leaves `exactForUnwatermarkedColumns`
false, so it is correct today, but a later fallback in this stack that relies
on this doc could reject joins that earlier versions admitted. Naming the
single check the flag skips, and saying that earlier versions' result also
needs `exactForUnwatermarkedColumns` left false, would make the doc accurate.
**Verification:**
- **Inspection:** The flag's doc matches the solver: it skips only the
TIMESTAMP and time-window column check, and the inexact-arithmetic rule stays
under exactForUnwatermarkedColumns.
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/operators/stateful/join/StreamingSymmetricHashJoinHelper.scala:
##########
@@ -224,98 +230,334 @@ object StreamingSymmetricHashJoinHelper extends Logging {
WatermarkSupport.findEventTimeColumn(rightAttributes,
allowMultipleEventTimeColumns = useFirstEventTimeColumn)
- val joinKeyOrdinalForWatermark: Option[Int] =
findJoinKeyOrdinalForWatermark(
- leftKeys, rightKeys)
-
def getOneSideStateWatermarkPredicate(
oneSideInputAttributes: Seq[Attribute],
oneSideJoinKeys: Seq[Expression],
- otherSideInputAttributes: Seq[Attribute]):
Option[JoinStateWatermarkPredicate] = {
- val isWatermarkDefinedOnInput =
oneSideInputAttributes.exists(_.metadata.contains(delayKey))
+ otherSideInputAttributes: Seq[Attribute],
+ otherSideJoinKeys: Seq[Expression]):
Option[JoinStateWatermarkPredicate] = {
+ // State is bounded by future input from the opposite side, not by its
own watermark.
+ val joinKeyOrdinalForWatermark =
StreamingJoinHelper.getStateKeyWatermarkOrdinal(
+ otherSideJoinKeys, otherSideInputAttributes)
val isWatermarkDefinedOnJoinKey = joinKeyOrdinalForWatermark.isDefined
if (isWatermarkDefinedOnJoinKey) { // case 1 and 3 in the
StreamingSymmetricHashJoinExec docs
+ val ordinal = joinKeyOrdinalForWatermark.get
val keyExprWithWatermark = BoundReference(
- joinKeyOrdinalForWatermark.get,
- oneSideJoinKeys(joinKeyOrdinalForWatermark.get).dataType,
- oneSideJoinKeys(joinKeyOrdinalForWatermark.get).nullable)
- val expr = watermarkExpression(Some(keyExprWithWatermark),
eventTimeWatermarkForEviction)
- expr.map { e =>
- // V4 can skip keys at or below the previous watermark only if
late-input filtering
- // rejects new rows in that range on this same key. A watermark on
the other input's
- // equality key can drive eviction even when this input has no
watermark, or has one
- // on a different column. New rows can then pass late-input
filtering with keys
- // already eligible for eviction. V4 must scan from the beginning to
find them;
- // otherwise, outer joins can fail to emit null rows for these
unmatched inputs.
- val prevStateKeyWatermark =
- if (oneSideInputAttributes.find(_.metadata.contains(delayKey))
-
.exists(oneSideJoinKeys(joinKeyOrdinalForWatermark.get).semanticEquals)) {
- eventTimeWatermarkForLateEvents
- } else {
- None
- }
- // watermarkExpression only provides the expression when
eventTimeWatermarkForEviction
- // is defined.
- JoinStateKeyWatermarkPredicate(
- e,
- eventTimeWatermarkForEviction.get,
- prevStateKeyWatermark)
- }
- } else if (isWatermarkDefinedOnInput) { // case 2 in the
StreamingSymmetricHashJoinExec docs
- val stateValueWatermark = StreamingJoinHelper.getStateValueWatermark(
- attributesToFindStateWatermarkFor =
AttributeSet(oneSideInputAttributes),
- attributesWithEventWatermark =
AttributeSet(otherSideInputAttributes),
- condition,
- eventTimeWatermarkForEviction)
- // A row can pass late-input filtering but already be eligible for
eviction in this batch.
- // When the previous join-derived state cutoff is ahead of the
late-input watermark, a new
- // row can fall at or below that cutoff. V4 must scan from the
beginning to find such rows.
- val prevStateValueWatermark = eventTimeWatermarkForLateEvents.flatMap
{ lateWatermark =>
- StreamingJoinHelper.getStateValueWatermark(
- attributesToFindStateWatermarkFor =
AttributeSet(oneSideInputAttributes),
- attributesWithEventWatermark =
AttributeSet(otherSideInputAttributes),
- condition,
- eventTimeWatermarkForLateEvents).filter(_ <= lateWatermark)
+ ordinal, oneSideJoinKeys(ordinal).dataType,
oneSideJoinKeys(ordinal).nullable)
+ // The opposite watermark bounds this key when the opposite key is
that input's event
+ // time, possibly shifted by constant intervals: by the shift for an
exact interval, and
+ // unshifted for whole days, months or years that never move a time
backward. See
+ // StreamingJoinHelper.getStateKeyWatermark for which shifts qualify.
+ def keyWatermark(watermark: Option[Long]): Option[Long] =
+ StreamingJoinHelper.getStateKeyWatermark(
+ otherSideJoinKeys, otherSideInputAttributes, ordinal, watermark)
+ keyWatermark(eventTimeWatermarkForEviction).flatMap { stateWatermark =>
+ watermarkExpression(Some(keyExprWithWatermark),
Some(stateWatermark)).map { e =>
+ // V4 can skip keys at or below the previous watermark only if
late-input filtering
+ // rejects new rows in that range on this same key. A watermark on
the other input's
+ // equality key can drive eviction even when this input has no
watermark, or has one
+ // on a different column. New rows can then pass late-input
filtering with keys
+ // already eligible for eviction. V4 must scan from the beginning
to find them;
+ // otherwise, outer joins can fail to emit null rows for these
unmatched inputs.
+ val prevStateKeyWatermark =
+ if (oneSideInputAttributes.find(_.metadata.contains(delayKey))
+ .exists(oneSideJoinKeys(ordinal).semanticEquals)) {
+ // Late filtering drops new keys at or below the late-input
watermark, and the
+ // previous batch evicted keys up to its cutoff, which is the
cutoff at that
+ // watermark. A shifted cutoff can lie on either side of the
watermark, so the
+ // scan starts after the lower of the two.
+ eventTimeWatermarkForLateEvents.flatMap { lateWatermark =>
+ keyWatermark(Some(lateWatermark)).map(math.min(_,
lateWatermark))
+ }
+ } else {
+ None
+ }
+ JoinStateKeyWatermarkPredicate(e, stateWatermark,
prevStateKeyWatermark)
+ }
}
- val inputAttributeWithWatermark =
oneSideInputAttributes.find(_.metadata.contains(delayKey))
- val expr = watermarkExpression(inputAttributeWithWatermark,
stateValueWatermark)
- expr.map { e =>
- // watermarkExpression only provides the expression when
eventTimeWatermarkForEviction
- // is defined
- JoinStateValueWatermarkPredicate(e, stateValueWatermark.get,
prevStateValueWatermark)
+ } else { // case 2 in the StreamingSymmetricHashJoinExec docs
+ // Future matches are limited by the opposite watermark. This input
needs no watermark;
+ // its event-time column may also have been pruned from the physical
join.
+ val otherSideEventTime =
otherSideInputAttributes.find(_.metadata.contains(delayKey))
+ getStateValueWatermarkForInput(oneSideInputAttributes,
otherSideInputAttributes,
+ condition, eventTimeWatermarkForEviction).flatMap { case (attribute,
watermark) =>
+ // Late filtering only constrains the input's event-time column. A
different indexed
+ // column can admit values below the previous cutoff and must be
scanned from the start.
+ val prevStateValueWatermark = eventTimeWatermarkForLateEvents.filter
{ _ =>
+ oneSideInputAttributes.find(_.metadata.contains(delayKey))
+ .exists(_.semanticEquals(attribute))
+ }.flatMap { lateWatermark =>
+ // Also scan from the start if the derived cutoff exceeds the
late-input watermark.
+
StreamingJoinHelper.getStateValueWatermark(AttributeSet(Seq(attribute)),
+ AttributeSet(otherSideEventTime.toSeq), condition,
Some(lateWatermark))
+ .filter(_ <= lateWatermark)
+ }
+ watermarkExpression(Some(attribute), Some(watermark)).map { e =>
+ JoinStateValueWatermarkPredicate(e, watermark,
prevStateValueWatermark)
+ }
}
- } else {
- None
}
}
val leftStateWatermarkPredicate =
- getOneSideStateWatermarkPredicate(leftAttributes, leftKeys,
rightAttributes)
+ getOneSideStateWatermarkPredicate(leftAttributes, leftKeys,
rightAttributes, rightKeys)
val rightStateWatermarkPredicate =
- getOneSideStateWatermarkPredicate(rightAttributes, rightKeys,
leftAttributes)
+ getOneSideStateWatermarkPredicate(rightAttributes, rightKeys,
leftAttributes, leftKeys)
JoinStateWatermarkPredicates(leftStateWatermarkPredicate,
rightStateWatermarkPredicate)
}
- private[join] def findJoinKeyOrdinalForWatermark(
+ /** Keep each cutoff attached to the column constrained by the join
condition. */
+ private def getStateValueWatermarkForInput(
+ inputAttributes: Seq[Attribute],
+ otherInputAttributes: Seq[Attribute],
+ condition: Option[Expression],
+ eventWatermark: Option[Long]): Option[(Attribute, Long)] = {
+ // TODO(SPARK-61349): a conjunct that uses only constants still caps the
cutoff, so it can
+ // stop eviction.
+ val eventTime = inputAttributes.find(_.metadata.contains(delayKey))
+ // Only the first marked column is checked for late input in compatibility
mode.
+ val otherEventTime =
otherInputAttributes.find(_.metadata.contains(delayKey))
+ // First try the watermarked column. If it has no inferable bound, try the
other timestamp
+ // and time-window columns in input schema order and use the first with a
bound. This makes
+ // the indexed column deterministic for a fixed input schema and join
condition. The solver
+ // gives a cutoff for no other column, so the admission check, which tries
every column,
+ // accepts the same bounds.
+ val candidates = eventTime.toSeq ++ inputAttributes.filter { attribute =>
+ StreamingJoinHelper.canTakeRangeCutoff(attribute) &&
Review Comment:
**Nit (P3):** The window part of `canTakeRangeCutoff` matters only when the
bounded window is not the input's event time: for example, an input watermarked
on `lt` with `lw = window(ot, "10 seconds")` over an unwatermarked `ot`, joined
on `lk = rk AND lw > rw` with a watermarked 10-second right window `rw`.
Admission accepts that join through `lw`; without this branch, eviction would
try only `lt`, find no bound and keep the left state, so a left outer join
would never output its unmatched windows. Every window test in this PR builds
its windows with the `windowed` helper, where the window is the input's only
watermarked column and so the first candidate, so no test fails if this branch
regresses.
**Verification:**
- **Regression:** A left outer stream-stream join whose only left bound
compares a window() column that is not the left input's event time with the
right input's watermarked window of the same length passes analysis and outputs
each unmatched left window once the eviction watermark passes its end, and an
inner join with that bound removes those windows from state.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -198,13 +477,80 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
}
}.reduceLeft(Add(_, _))
+ // Callers can pass only the constrained column and the opposite event
time, so a term on any
+ // other column passes the occurrence check above. Its value is unknown
here.
+ if (exprWithWatermarkSubstituted.references.nonEmpty) {
+ logDebug(s"Failed to extract state constraint: unresolved
$exprWithWatermarkSubstituted")
+ return None
+ }
+
// Calculate the constraint value
logInfo(log"Final expression to evaluate " +
log"constraint:\t${MDC(WATERMARK_CONSTRAINT,
exprWithWatermarkSubstituted)}")
val constraintValue =
exprWithWatermarkSubstituted.eval().asInstanceOf[java.lang.Double]
Some((Double2double(constraintValue) / 1000.0).toLong)
}
+ /** Whether a column of a join input can take a range cutoff: TIMESTAMP, or
a time window. */
+ def canTakeRangeCutoff(column: Attribute): Boolean =
+ column.dataType == TimestampType || windowDuration(column).isDefined
+
+ /** The length of the windows in a column built by window(), when the column
records it. */
+ private def windowDuration(column: Attribute): Option[Long] = {
+ val metadata = column.metadata
+ if (metadata.contains(TimeWindow.marker) &&
metadata.contains(TimeWindow.durationKey)) {
+ Some(metadata.getLong(TimeWindow.durationKey))
Review Comment:
**Non-blocking (P2):** This reads the window length from the column's
metadata, but a union's output column carries only its first child's metadata:
`Union.mergeChildOutputs` and `UnionExec.output` copy the first child's
attribute. So a union of `window()` columns with different lengths, or of a
`window()` column and another struct of the same type, records one length for
the rows of every child, and both the analysis check and eviction trust it.
For example, by this review's reading of the code: the left input has
10-second tumbling windows, and the right input is `c.union(d)`, where `c` has
10-second tumbling windows and `d` has 20-second windows sliding by 1 second,
all built by `window()` over watermarked columns, joined on `lk = rk AND lw >
rw`. The right column records `c`'s 10 seconds, so `isWindowEvictionSafe`
passes and the left windows are evicted by their end. With the watermark at 15
seconds, left window [0, 10) is evicted, yet a later right row from `d` at 18
seconds falls in window [-1, 19), which is not late and orders below [0, 10),
so the join misses that match. A left outer join with the same bound passes
analysis and emits [0, 10) as unmatched before that match arrives. A left union
whose first child has the longer windows loses matches the same way against
sliding right windows of that length.
The base branch drops these matches too, so this is the part of the
shorter-window failure this PR fixes that the fix does not reach yet.
This extends an [existing
discussion](https://github.com/apache/spark/pull/60283#discussion_r4523339214).
**Recommended change:** Keep spark.timeWindow.durationUs on a union's merged
column only when every child's column records the same value, applying one
shared rule, kept next to TimeWindow.durationKey, in Union.mergeChildOutputs
and in UnionExec.output, keep the rest of the first child's metadata, and add
stream-stream join tests over unions of window columns with different lengths
on either input.
**Why this works:** The window-length rule reads only the merged attribute.
Dropping the key whenever the children disagree makes windowDuration return no
length for that column, so isWindowEvictionSafe is false and the solver gives
no whole-window cutoff, as for any struct that records no length, in both the
analysis check and eviction; unions whose children agree keep the key and their
cutoffs.
**Scope:** Union output metadata keeps the window-length key only when every
child agrees, with join tests over such unions.
**Compatibility:** Union output metadata other than the window-length key,
and the key itself for unions whose children agree, stay unchanged.
**Risks:** A union whose children's window columns record different lengths
no longer shows the length key in its output schema, which users can see in
Dataset schemas and in sink and state schemas that keep field metadata; the
state schema check accepts metadata-only differences, so restarts proceed. Such
a union can no longer take a whole-window range cutoff: an inner join over it
keeps that input's state and holds back its output watermark for that input,
and an outer or left semi join bounded only that way fails analysis, as for any
window of unknown length; reverting the merge change restores the current
behavior.
**Constraints:** Keep every other metadata key of the first child's column,
including the window marker and the watermark delay key. Keep the length key
when every child's column records the same length, so unions of equal windows
keep their cutoffs. Apply the same rule to the logical and the physical union
outputs, so the analysis check and eviction agree.
**Exclusions:**
- Window columns read back from data written through such a union before
this change keep the length in their stored schema; the repair does not rewrite
stored schemas.
- Structs that user code labels with the window metadata keys stay out of
scope.
**Success:** A union of window() columns whose children record different
lengths outputs a column without spark.timeWindow.durationUs in both the
logical and the physical plan, while a union of equal-length windows keeps the
key. A stream-stream join whose stored or other input is such a union gets no
whole-window cutoff: an inner join keeps those rows, and an outer or left semi
join bounded only that way fails analysis with the rule.
**Verification:**
- **Regression:** An inner stream-stream join of 10-second left windows with
a right input that unions 10-second tumbling windows and 20-second windows
sliding by 1 second, bounded only by a whole-window comparison, still matches a
left window with a later 20-second right window after the watermark passes the
left window's end, and the same bound fails analysis in a left outer join.
- **Regression:** With a left input that unions 20-second and 10-second
windows, joined with 20-second right windows sliding by 1 second by a
whole-window comparison, the 10-second left windows stay in state, so a later
right window that orders below one of them still matches it.
- **Behavior:** A union of window() columns with different lengths, or of a
window() column and a struct that records no length, has no window-length key
in its output schema in both the logical and the physical plan, and a union of
equal-length windows keeps the key with the same value.
- **Compatibility:** Whole-window joins over a single window() column, or
over a union of equal-length windows, pass analysis and evict exactly as before
in every join state format.
--
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]