HeartSaVioR commented on code in PR #60284:
URL: https://github.com/apache/spark/pull/60284#discussion_r4536408763


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +297,22 @@ 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
+      case _ => false
+    }
+    if (!hasTimestampStateAttribute) return None
+
+    // A bound must advance with the opposite watermark. The occurrence check 
above limits
+    // each input to one attribute, so there can be at most one opposite 
watermark term.
+    val watermarkTerms = 
terms.filter(_.references.exists(attributesWithEventWatermark.contains))
+    if (watermarkTerms.isEmpty ||

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.
   
   Agreed, and thanks for the corrected example. In 
[c1e67e66de4](https://github.com/apache/spark/pull/60284/commits/c1e67e66de4ca23467bdf8f162df9ce424e7fde4),
 a constant-only conjunct is left out only when every other bound on the column 
is exact. If a bound on the column uses inexact arithmetic, the constant's 
cutoff stays in the minimum, as on the base branch. Inexact here means the rule 
SPARK-61347 already uses: a truncating cast, or whole days in a session time 
zone that is not a fixed offset. Your example now keeps the left row at 15.5 s 
and returns its match with the right row at 10.95 s, in V2, V3 and V4. This 
PR's target case, an exact range bound plus `CAST(lt AS BIGINT) > 10`, still 
evicts. An inexact bound without a constant keeps its current cutoff; 
SPARK-61381 covers that.
   
   <!-- sp2k-review2 reply 4531208064 -->
   



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/StreamingJoinHelper.scala:
##########
@@ -186,6 +297,22 @@ 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
+      case _ => false
+    }
+    if (!hasTimestampStateAttribute) return None
+
+    // A bound must advance with the opposite watermark. The occurrence check 
above limits

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 in 
[c1e67e66de4](https://github.com/apache/spark/pull/60284/commits/c1e67e66de4ca23467bdf8f162df9ce424e7fde4):
 a TODO at the check names negative watermark terms and SPARK-61350. #60286 
replaces it with the sign test.
   
   <!-- sp2k-review2 reply 4531208459 -->
   



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