Github user zsxwing commented on a diff in the pull request:
https://github.com/apache/spark/pull/9922#discussion_r45803191
--- Diff:
streaming/src/main/scala/org/apache/spark/streaming/api/python/PythonDStream.scala
---
@@ -59,18 +74,32 @@ private[python] class TransformFunction(@transient var
pfunc: PythonTransformFun
extends function.Function2[JList[JavaRDD[_]], Time,
JavaRDD[Array[Byte]]] {
def apply(rdd: Option[RDD[_]], time: Time): Option[RDD[Array[Byte]]] = {
- Option(pfunc.call(time.milliseconds,
List(rdd.map(JavaRDD.fromRDD(_)).orNull).asJava))
- .map(_.rdd)
+ val resultRDD = pfunc.call(time.milliseconds,
List(rdd.map(JavaRDD.fromRDD(_)).orNull).asJava)
+ val failure = pfunc.getLastFailure
+ if (failure != null) {
+ throw new SparkException("An exception was raised by Python:\n" +
failure)
+ }
+ Option(resultRDD).map(_.rdd)
}
def apply(rdd: Option[RDD[_]], rdd2: Option[RDD[_]], time: Time):
Option[RDD[Array[Byte]]] = {
val rdds = List(rdd.map(JavaRDD.fromRDD(_)).orNull,
rdd2.map(JavaRDD.fromRDD(_)).orNull).asJava
- Option(pfunc.call(time.milliseconds, rdds)).map(_.rdd)
+ val resultRDD = pfunc.call(time.milliseconds, rdds)
+ val failure = pfunc.getLastFailure
+ if (failure != null) {
+ throw new SparkException("An exception was raised by Python:\n" +
failure)
+ }
+ Option(resultRDD).map(_.rdd)
}
// for function.Function2
def call(rdds: JList[JavaRDD[_]], time: Time): JavaRDD[Array[Byte]] = {
--- End diff --
This one is not used in any place. So I cannot write a test for it.
---
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]