heyihong commented on code in PR #42377: URL: https://github.com/apache/spark/pull/42377#discussion_r1323060159
########## connector/connect/client/jvm/src/test/scala/org/apache/spark/sql/streaming/ClientStreamingQuerySuite.scala: ########## @@ -175,6 +175,36 @@ class ClientStreamingQuerySuite extends QueryTest with SQLHelper with Logging { } } + test("throw exception in streaming") { + val session = spark + import session.implicits._ + + val checkForTwo = udf((value: Int) => { + if (value == 2) { + throw new RuntimeException("Number 2 encountered!") + } + value + }) + + val query = spark.readStream + .format("rate") + .option("rowsPerSecond", "1") + .load() + .select(checkForTwo($"value").as("checkedValue")) + .writeStream + .outputMode("append") + .format("console") + .start() + + val exception = intercept[SparkException] { + query.awaitTermination() + } + + assert( + exception.getCause.getCause.getCause.getMessage Review Comment: org.apache.spark.sql.streaming.StreamingQueryException: Job aborted due to stage failure: Task 0 in stage 1384542.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1384542.0 (TID 55303014) (10.139.68.71 executor 781): org.apache.spark.SparkException: [FAILED_EXECUTE_UDF] Failed to execute user defined function (`$Lambda$19844/1935914328`: (int) => int). at org.apache.spark.sql.errors.QueryExecutionErrors$.failedExecuteUserDefinedFunctionError(QueryExecutionErrors.scala:244) at org.apache.spark.sql.errors.QueryExecutionErrors.failedExecuteUserDefinedFunctionError(QueryExecutionErrors.scala) at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown Source) at org.apache.spark.sql.execution.BufferedRowIterator.hasNext(BufferedRowIterator.java:43) org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1384542.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1384542.0 (TID 55303014) (10.139.68.71 executor 781): org.apache.spark.SparkException: [FAILED_EXECUTE_UDF] Failed to execute user defined function (`$Lambda$19844/1935914328`: (int) => int). at org.apache.spark.sql.errors.QueryExecutionErrors$.failedExecuteUserDefinedFunctionError(QueryExecutionErrors.scala:244) at org.apache.spark.sql.errors.QueryExecutionErrors.failedExecuteUserDefinedFunctionError(QueryExecutionErrors.scala) at org.apache.spark.sql.catalyst.expressions.GeneratedClass$GeneratedIteratorForCodegenStage1.processNext(Unknown Source) org.apache.spark.SparkException: [FAILED_EXECUTE_UDF] Failed to execute user defined function (`$Lambda$19844/1935914328`: (int) => int). java.lang.RuntimeException: Number 2 encountered! -- 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. To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org