Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/15949#discussion_r89744923
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/streaming/WatermarkSuite.scala ---
@@ -96,27 +96,42 @@ class WatermarkSuite extends StreamTest with
BeforeAndAfter with Logging {
)
}
- ignore("recovery") {
+ test("recovery") {
val inputData = MemoryStream[Int]
-
- val windowedAggregation = inputData.toDF()
- .withColumn("eventTime", $"value".cast("timestamp"))
- .withWatermark("eventTime", "10 seconds")
- .groupBy(window($"eventTime", "5 seconds") as 'window)
- .agg(count("*") as 'count)
- .select($"window".getField("start").cast("long").as[Long],
$"count".as[Long])
-
- testStream(windowedAggregation)(
+ val df = inputData.toDF()
+ .withColumn("eventTime", $"value".cast("timestamp"))
+ .withWatermark("eventTime", "10 seconds")
+ .groupBy(window($"eventTime", "5 seconds") as 'window)
+ .agg(count("*") as 'count)
+ .select($"window".getField("start").cast("long").as[Long],
$"count".as[Long])
+ val outputMode = OutputMode.Append
+ val memorySink = new MemorySink(df.schema, outputMode)
+ testStream(df)(
AddData(inputData, 10, 11, 12, 13, 14, 15),
CheckAnswer(),
AddData(inputData, 25), // Advance watermark to 15 seconds
StopStream,
StartStream(),
- CheckAnswer(),
+ CheckLastBatch(),
AddData(inputData, 25), // Evict items less than previous watermark.
+ CheckLastBatch((10, 5)),
StopStream,
+ AssertOnQuery { q => // clear the sink
+ q.sink.asInstanceOf[MemorySink].clear()
+ true
+ },
StartStream(),
- CheckAnswer((10, 5))
+ CheckLastBatch((10, 5)),
--- End diff --
nit: add comment to explain // Should recompute the last batch and
re-evict timestamp 10
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]