WweiL commented on code in PR #44323:
URL: https://github.com/apache/spark/pull/44323#discussion_r1428568077


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/StreamingSymmetricHashJoinHelper.scala:
##########
@@ -218,11 +223,27 @@ object StreamingSymmetricHashJoinHelper extends Logging {
           attributesToFindStateWatermarkFor = 
AttributeSet(oneSideInputAttributes),
           attributesWithEventWatermark = 
AttributeSet(otherSideInputAttributes),
           condition,
-          eventTimeWatermarkForEviction)
-        val inputAttributeWithWatermark = 
oneSideInputAttributes.find(_.metadata.contains(delayKey))
-        val expr = watermarkExpression(inputAttributeWithWatermark, 
stateValueWatermark)
-        expr.map(JoinStateValueWatermarkPredicate.apply _)
+          eventTimeWatermarkForEviction
+        )
+
+        val attributesInCondition = AttributeSet(
+          condition.get.collect { case a: AttributeReference => a }
+        )
 
+        // Find the attribute that isn't the watermark attribute
+        val stateWatermarkAttributeSeq = attributesInCondition
+          .filterNot(_.semanticEquals(watermarkAttribute.get))
+          .toSeq
+
+        if (stateWatermarkAttributeSeq.size == 1) {
+          val expr = 
watermarkExpression(Some(stateWatermarkAttributeSeq.head), stateValueWatermark)
+          expr.map(JoinStateValueWatermarkPredicate.apply _)
+        } else {
+          // This should never happen, since if we have two attributes from 
the condition
+          // and one watermark (which we have, since isWatermarkDefinedOnInput 
is true),
+          // we should have one state watermark.
+          None

Review Comment:
   if the schema is "v1, v2, ts" for both side of streams. And join condition 
is 
   `l.v1 = r.v1 AND l.v2 = r.v2 AND r.ts > l.ts + INTERVAL 10 seconds" 
   this would break right?



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