zsxwing commented on a change in pull request #23513: [SPARK-26586][SS] Fix
race condition that causes streams to run with unexpected confs
URL: https://github.com/apache/spark/pull/23513#discussion_r246924724
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/streaming/test/DataStreamReaderWriterSuite.scala
##########
@@ -651,4 +652,24 @@ class DataStreamReaderWriterSuite extends StreamTest with
BeforeAndAfter {
LastOptions.clear()
}
+
+ test("SPARK-26586: Streams should have isolated confs") {
+ import testImplicits._
+ val input = MemoryStream[Int]
+ input.addData(1 to 10)
+ spark.conf.set("testKey1", 0)
+ val queries = (1 to 10).map { i =>
+ spark.conf.set("testKey1", i)
+ input.toDF().writeStream
+ .foreachBatch { (df: Dataset[Row], id: Long) =>
+ val v = df.sparkSession.conf.get("testKey1").toInt
+ if (i != v) {
+ throw new ConcurrentModificationException(s"Stream $i has the
wrong conf value $v")
+ }
+ }
+ .start()
+ }
+ queries.foreach(_.processAllAvailable())
+ queries.foreach(_.stop())
Review comment:
nit: could you put this line in `finally`?
----------------------------------------------------------------
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]