Github user felixcheung commented on a diff in the pull request: https://github.com/apache/spark/pull/18306#discussion_r122122675 --- Diff: sql/core/src/test/scala/org/apache/spark/sql/streaming/StreamingQueryManagerSuite.scala --- @@ -239,6 +237,40 @@ class StreamingQueryManagerSuite extends StreamTest with BeforeAndAfter { } } + test("stopAllQueries") { + val datasets = Seq.fill(5)(makeDataset._2) + withQueriesOn(datasets: _*) { queries => + assert(queries.forall(_.isActive)) + spark.streams.stopAllQueries() + assert(queries.forall(_.isActive == false), "Queries are still running") + } + } + + test("stop session stops all queries") { + val inputData = MemoryStream[Int] + val mapped = inputData.toDS.map(6 / _) + var query: StreamingQuery = null + try { + query = mapped.toDF.writeStream + .format("memory") + .queryName(s"queryInNewSession") + .outputMode("append") + .start() + assert(query.isActive) + spark.stop() + assert(spark.sparkContext.isStopped) + assert(query.isActive == false, "Query is still running") + } catch { + case NonFatal(e) => + if (query != null) query.stop() + throw e --- End diff -- why still try/catch to stop the query? since this is a test of this specific behavior, if the query isn't stopped, or throws, the test actually is failing? more importantly, why ignore NonFatal exception thrown?
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org