HeartSaVioR commented on code in PR #60667:
URL: https://github.com/apache/spark/pull/60667#discussion_r4621518928
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/operators/stateful/join/StreamingSymmetricHashJoinExec.scala:
##########
@@ -722,6 +744,16 @@ case class StreamingSymmetricHashJoinExec(
private[this] val allowMultipleStatefulOperators: Boolean =
conf.getConf(SQLConf.STATEFUL_OPERATOR_ALLOW_MULTIPLE)
+ // The join condition bounds the column that the value predicate tests, so
a row with a NULL
+ // in it can never match, and the predicate never evicts it. The legacy
mode tests the event
+ // time even when the condition bounds another column.
+ private[this] val isEvictionColumnNull: UnsafeRow => Boolean =
stateWatermarkPredicate match {
+ case Some(JoinStateValueWatermarkPredicate(LessThanOrEqual(column, _),
_, _))
+ if allowMultipleStatefulOperators =>
+ Predicate.create(IsNull(column), inputAttributes).eval _
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.
Added a test: on state formats 2 and 4, a left row with a NULL event time is
emitted as an outer row on arrival and not stored.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -117,6 +117,27 @@ object StreamingJoinHelper extends PredicateHelper with
Logging {
allStateWatermarks.reduceOption((x, y) => Math.min(x, y))
}
+ /**
+ * Get the column that evicts the state of an input with its own watermark,
with its state value
+ * watermark. That is the event time if the condition bounds it, and
otherwise the first other
+ * TIMESTAMP column in input order that the condition bounds. Each column is
solved on its own,
+ * so the cutoff applies to the column that the condition bounds.
+ */
+ def getStateValueWatermarkColumn(
+ inputAttributes: Seq[Attribute],
+ attributesWithEventWatermark: AttributeSet,
+ joinCondition: Option[Expression],
+ eventWatermark: Option[Long]): Option[(Attribute, Long)] = {
+ val eventTime = inputAttributes.find(_.metadata.contains(delayKey))
+ val candidates = eventTime.toSeq ++ inputAttributes.filter { a =>
+ a.dataType == TimestampType && !eventTime.exists(_.semanticEquals(a))
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.
Added a test that the column pick returns no column for a TIMESTAMP_NTZ
column. Such an input now keeps the earlier eviction by its event time, so
there is no analysis case.
##########
docs/streaming/ss-migration-guide.md:
##########
@@ -25,6 +25,16 @@ Please refer [Migration Guide: SQL, Datasets and
DataFrame](../sql-migration-gui
## Upgrading from Structured Streaming 4.3 to 4.4
+- Since Spark 4.4, a stream-stream join whose condition bounds an input with
its own watermark
+ only through another TIMESTAMP column, for example `rightTime BETWEEN
leftTime AND expiry`,
+ evicts the state of that input by the bounded column instead of its event
time. Earlier versions
+ could emit outer join rows too early and lose matches. An outer or left semi
join whose only such
+ bound is on a column that is not TIMESTAMP, such as a DATE column cast to
TIMESTAMP, now fails
+ analysis. Such a join with state format version 4 cannot restart from a
checkpoint of an earlier
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.
Rewritten: the entry now names the join it is about, the state format 4
restart failure, and the rows not restored on state formats 1 to 3.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/UnsupportedOperationChecker.scala:
##########
@@ -708,20 +708,23 @@ object UnsupportedOperationChecker extends Logging {
private def checkForStreamStreamJoinWatermark(join: Join): Unit = {
val watermarkInJoinKeys = StreamingJoinHelper.isWatermarkInJoinKeys(join)
+ // Execution evicts the state of an input with its own watermark only by
the column that
+ // getStateValueWatermarkColumn picks, such as not by a DATE column cast
to TIMESTAMP.
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.
That comment is gone: the checker change was reverted.
--
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]