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


##########
sql/core/src/test/scala/org/apache/spark/sql/streaming/MultiStatefulOperatorsSuite.scala:
##########
@@ -814,68 +814,183 @@ class MultiStatefulOperatorsSuite
     }
   }
 
-  test("stream-stream time interval join - output watermark for various 
intervals") {
-    def testOutputWatermarkInJoin(
-        df: DataFrame,
-        input: MemoryStream[(String, Timestamp)],
-        expectedOutputWatermark: Long): Unit = {
-      testStream(df)(
-        // dummy row to trigger execution
-        AddData(input, ("1", Timestamp.valueOf("2023-01-01 01:00:10"))),
-        CheckAnswer(),
-        Execute { query =>
-          val lastExecution = query.lastExecution
-          val joinOperator = lastExecution.executedPlan.collect {
-            case j: StreamingSymmetricHashJoinExec => j
-          }.head
+  test("SPARK-45637-1 join on window, append mode") {
+    val impressions = MemoryStream[Int]
+    val clicks = MemoryStream[Int]
 
-          val outputWatermark = joinOperator.produceOutputWatermark(0)
-          assert(outputWatermark.get === expectedOutputWatermark)
-        }
+    val impressionsWithWatermark = impressions.toDF()
+      .withColumn("impressionTime", timestamp_seconds($"value"))
+      .withColumnRenamed("value", "impressionAdId")
+      .withWatermark("impressionTime", "0 seconds")
+
+    // clickTime is always later than impressionTime for clickAdId = 
impressionAdId
+    // Here we manually set the difference to 2 seconds (see the 
(Multi)AddData below)
+    val clicksWithWatermark = clicks.toDF()
+      .withColumn("timeSec", timestamp_seconds($"value"))
+      .selectExpr("value as clickAdId", "timeSec + INTERVAL 2 seconds as 
clickTime")
+      .withWatermark("clickTime", "0 seconds")
+
+    val clicksWindow = clicksWithWatermark.select(
+      window($"clickTime", "5 seconds")
+    )
+
+    val impressionsWindow = impressionsWithWatermark.select(
+      window($"impressionTime", "5 seconds")
+    )
+
+    val clicksAndImpressions = clicksWindow.join(impressionsWindow, "window", 
"inner")
+
+    withSQLConf((SQLConf.SHUFFLE_PARTITIONS.key, "1")) {
+      testStream(clicksAndImpressions)(
+        MultiAddData(
+          (impressions, Seq(0 to 8: _*)),
+          (clicks, Seq(1, 6))
+        ),
+        CheckAnswer((0, 5, 5, 1))
       )
     }
+  }
 
-    val input1 = MemoryStream[(String, Timestamp)]
-    val df1 = input1.toDF()
-      .selectExpr("_1 as leftId", "_2 as leftEventTime")
-      .withWatermark("leftEventTime", "5 minutes")
+  test("SPARK-45637 window agg + window agg -> join on window, append mode") {

Review Comment:
   This is the test ran



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to