You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/02/19 00:50:08 UTC

[GitHub] HeartSaVioR 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

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

 ##########
 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:
   If I'm not missing here, max timestamp on both are 10. Left and right only differ when the last value ends with odd value. Please take a look at the result: `(10, 10L, 10, 10L)` is one of result on matched.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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