zsxwing commented on a change in pull request #24382: [SPARK-27330][SS] support
task abort in foreach writer
URL: https://github.com/apache/spark/pull/24382#discussion_r313547874
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/ForeachWriterSuite.scala
##########
@@ -286,6 +293,71 @@ object ForeachWriterSuite {
}
}
+class ForeachWriterAbortSuite extends StreamTest with SharedSQLContext with
BeforeAndAfter {
Review comment:
Here is the regression test I meant:
```Scala
testQuietly("foreach with error not caused by ForeachWriter") {
withTempDir { checkpointDir =>
val input = MemoryStream[Int]
val query = input.toDS().repartition(1).map(_ / 0).writeStream
.option("checkpointLocation", checkpointDir.getCanonicalPath)
.foreach(new TestForeachWriter)
.start()
input.addData(1, 2, 3, 4)
val e = intercept[StreamingQueryException] {
query.processAllAvailable()
}
assert(e.getCause.isInstanceOf[SparkException])
assert(e.getCause.getCause.getCause.getMessage === "/ by zero")
assert(query.isActive === false)
val allEvents = ForeachWriterSuite.allEvents()
assert(allEvents.size === 1)
assert(allEvents(0)(0) === ForeachWriterSuite.Open(partition = 0,
version = 0))
// `close` should be called with the error
val errorEvent = allEvents(0)(1).asInstanceOf[ForeachWriterSuite.Close]
assert(errorEvent.error.get.isInstanceOf[SparkException])
assert(errorEvent.error.get.getMessage ===
"Foreach writer has been aborted due to a task failure")
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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]