Github user harishreedharan commented on a diff in the pull request:
https://github.com/apache/spark/pull/8881#discussion_r40177949
--- Diff:
streaming/src/test/scala/org/apache/spark/streaming/BasicOperationsSuite.scala
---
@@ -210,6 +210,18 @@ class BasicOperationsSuite extends TestSuiteBase {
input.map(_.map(_.toString))
)
}
+
+ test("transform with NULL") {
+ val input = Seq(1 to 4, Seq(), 5 to 8, 9 to 12)
+ testOperation(
+ input,
+ (r: DStream[Int]) => r.transform(rdd => {if (rdd != null &&
!rdd.isEmpty()) rdd.map(_.toString) else null}), // RDD.map in transform
+ input.filter(!_.isEmpty).map(_.map(_.toString)),
+ 4,
+ false
+ )
+ }
--- End diff --
nit: The formatting here is pretty weird. Maybe take the transformation
method out and separate it out as a `def`, so this method call can be in a
single line:
```
def transformMethod(r: DStream[Int]): Option[RDD] = {
r.transform { rdd =>
if (rdd != null && !rdd.isEmpty()) rdd.map(_.toString) else null
}
}
testOperation(input, transformMethod,
input.filter(!_.isEmpty).map(_.map(_.toString)), 4, false)
```
---
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]