Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/17216#discussion_r105781560
--- Diff:
sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamSuite.scala ---
@@ -389,6 +390,61 @@ class StreamSuite extends StreamTest {
query.stop()
assert(query.exception.isEmpty)
}
+
+ test("SPARK-19873: streaming aggregation with change in number of
partitions") {
+ val inputData = MemoryStream[(Int, Int)]
+ val agg = inputData.toDS().groupBy("_1").count()
+
+ testStream(agg, OutputMode.Complete())(
+ AddData(inputData, (1, 0), (2, 0)),
+ StartStream(additionalConfs = Map(SQLConf.SHUFFLE_PARTITIONS.key ->
"2")),
+ CheckAnswer((1, 1), (2, 1)),
+ StopStream,
+ AddData(inputData, (3, 0), (2, 0)),
+ StartStream(additionalConfs = Map(SQLConf.SHUFFLE_PARTITIONS.key ->
"5")),
+ CheckAnswer((1, 1), (2, 2), (3, 1)),
+ StopStream,
+ AddData(inputData, (3, 0), (1, 0)),
+ StartStream(additionalConfs = Map(SQLConf.SHUFFLE_PARTITIONS.key ->
"1")),
+ CheckAnswer((1, 2), (2, 2), (3, 2)))
+ }
+
+ test("SPARK-19873: backward compat with checkpoints that do not record
shuffle partitions") {
+ val inputData = MemoryStream[Int]
+ inputData.addData(1, 2, 3, 4)
+ inputData.addData(3, 4, 5, 6)
+ inputData.addData(5, 6, 7, 8)
+
+ val resourceUri =
+
this.getClass.getResource("/structured-streaming/checkpoint-version-2.1.0").toURI
+ val checkpointDir = new File(resourceUri).getCanonicalPath
+ val query = inputData
+ .toDF()
+ .groupBy($"value")
+ .agg(count("*"))
+ .writeStream
+ .queryName("counts")
+ .outputMode("complete")
+ .option("checkpointLocation", checkpointDir)
+ .format("memory")
+
+ // Checkpoint data was generated by a query with 10 shuffle partitions.
+ // Test if recovery from checkpoint is successful.
+ withSQLConf(SQLConf.SHUFFLE_PARTITIONS.key -> "10") {
+ query.start().processAllAvailable()
--- End diff --
its not clear that this would actually re-execute a batch. unless a batch
is executed, this does not test anything. so how about you add more data after
processAllAvailable(), to ensure that at least one batch is actually executed?
---
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]