tdas commented on a change in pull request #23634: [SPARK-26154][SS] Streaming 
left/right outer join should not return outer nulls for already matched rows
URL: https://github.com/apache/spark/pull/23634#discussion_r257547812
 
 

 ##########
 File path: 
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingJoinSuite.scala
 ##########
 @@ -712,5 +708,186 @@ class StreamingOuterJoinSuite extends StreamTest with 
StateStoreMetricsTest with
       assertNumStateRows(total = 2, updated = 2)
     )
   }
+
+  test("SPARK-26187 self left outer join should not return outer nulls for 
already matched rows") {
+    val inputStream = MemoryStream[(Int, Long)]
+
+    val df = inputStream.toDS()
+      .select(col("_1").as("value"), 
col("_2").cast("timestamp").as("timestamp"))
+
+    val fooStream = df.select(col("value").as("fooId"), 
col("timestamp").as("fooTime"))
+
+    val barStream = df
+      // Introduce misses for ease of debugging
+      .where(col("value") % 2 === 0)
+      .select(col("value").as("barId"), col("timestamp").as("barTime"))
+
+    val query = fooStream
+      .withWatermark("fooTime", "5 seconds")
+      .join(
+        barStream.withWatermark("barTime", "5 seconds"),
+        expr("barId = fooId AND barTime >= fooTime AND barTime <= fooTime + 
interval 5 seconds"),
+        joinType = "leftOuter")
+      .select(col("fooId"), col("fooTime").cast("int"),
+        col("barId"), col("barTime").cast("int"))
+
+    testStream(query)(
+      AddData(inputStream, (1, 1L), (2, 2L), (3, 3L), (4, 4L), (5, 5L)),
+      // batch 1 - global watermark = 0
+      // states
+      // left: (1, 1L), (2, 2L), (3, 3L), (4, 4L), (5, 5L)
+      // right: (2, 2L), (4, 4L)
+      CheckNewAnswer((2, 2L, 2, 2L), (4, 4L, 4, 4L)),
+      assertNumStateRows(7, 7),
+
+      AddData(inputStream, (6, 6L), (7, 7L), (8, 8L), (9, 9L), (10, 10L)),
+      // batch 2 - global watermark = 5
 
 Review comment:
   this should global watermark = 3  <= min(5, 3)   as  max timestamp on left = 
10, on right = 8

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to