{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/40177949","id":40177949,"diff_hunk":"@@ -210,6 +210,18 @@ class BasicOperationsSuite extends TestSuiteBase {\n       input.map(_.map(_.toString))\n     )\n   }\n+  \n+  test(\"transform with NULL\") {\n+    val input = Seq(1 to 4, Seq(), 5 to 8, 9 to 12)\n+    testOperation(\n+      input,\n+      (r: DStream[Int]) => r.transform(rdd => {if (rdd != null && !rdd.isEmpty()) rdd.map(_.toString) else null}),   // RDD.map in transform\n+      input.filter(!_.isEmpty).map(_.map(_.toString)),\n+      4, \n+      false\n+    )\n+  }","path":"streaming/src/test/scala/org/apache/spark/streaming/BasicOperationsSuite.scala","position":14,"original_position":14,"commit_id":"c1e00ec88ac3c506f78d1e98fcfcc9a1c8e55a70","original_commit_id":"c1e00ec88ac3c506f78d1e98fcfcc9a1c8e55a70","user":{"login":"harishreedharan","id":1481194,"avatar_url":"https://avatars.githubusercontent.com/u/1481194?v=3","gravatar_id":"","url":"https://api.github.com/users/harishreedharan","html_url":"https://github.com/harishreedharan","followers_url":"https://api.github.com/users/harishreedharan/followers","following_url":"https://api.github.com/users/harishreedharan/following{/other_user}","gists_url":"https://api.github.com/users/harishreedharan/gists{/gist_id}","starred_url":"https://api.github.com/users/harishreedharan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harishreedharan/subscriptions","organizations_url":"https://api.github.com/users/harishreedharan/orgs","repos_url":"https://api.github.com/users/harishreedharan/repos","events_url":"https://api.github.com/users/harishreedharan/events{/privacy}","received_events_url":"https://api.github.com/users/harishreedharan/received_events","type":"User","site_admin":false},"body":"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:\r\n\r\n```\r\ndef transformMethod(r: DStream[Int]): Option[RDD] = {\r\n  r.transform { rdd => \r\n    if (rdd != null && !rdd.isEmpty()) rdd.map(_.toString) else null\r\n  }\r\n}\r\n\r\ntestOperation(input, transformMethod, input.filter(!_.isEmpty).map(_.map(_.toString)), 4, false)\r\n```","created_at":"2015-09-23T07:53:39Z","updated_at":"2015-09-23T07:53:39Z","html_url":"https://github.com/apache/spark/pull/8881#discussion_r40177949","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/8881","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/40177949"},"html":{"href":"https://github.com/apache/spark/pull/8881#discussion_r40177949"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/8881"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/8881","id":45749167,"html_url":"https://github.com/apache/spark/pull/8881","diff_url":"https://github.com/apache/spark/pull/8881.diff","patch_url":"https://github.com/apache/spark/pull/8881.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/8881","number":8881,"state":"open","locked":false,"title":"[SPARK-10772][Streaming][Scala]: NullPointerException when transform function in DStream returns NULL","user":{"login":"jhu-chang","id":10203485,"avatar_url":"https://avatars.githubusercontent.com/u/10203485?v=3","gravatar_id":"","url":"https://api.github.com/users/jhu-chang","html_url":"https://github.com/jhu-chang","followers_url":"https://api.github.com/users/jhu-chang/followers","following_url":"https://api.github.com/users/jhu-chang/following{/other_user}","gists_url":"https://api.github.com/users/jhu-chang/gists{/gist_id}","starred_url":"https://api.github.com/users/jhu-chang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhu-chang/subscriptions","organizations_url":"https://api.github.com/users/jhu-chang/orgs","repos_url":"https://api.github.com/users/jhu-chang/repos","events_url":"https://api.github.com/users/jhu-chang/events{/privacy}","received_events_url":"https://api.github.com/users/jhu-chang/received_events","type":"User","site_admin":false},"body":"Currently, the ```TransformedDStream``` will using ```Some(transformFunc(parentRDDs, validTime))``` as compute return value, when the ```transformFunc``` somehow returns null as return value, the followed operator will have NullPointerExeception.\r\n\r\nThis fix uses the ```Option()``` instead of ```Some()``` to deal with the possible null value. When   ```transformFunc``` returns ```null```, the option will transform null to ```None```, the downstream can handle ```None``` correctly.  ","created_at":"2015-09-23T07:11:11Z","updated_at":"2015-09-23T07:53:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c00cead2a3ace3beb77f9b01c8b71fdbbf356c98","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/8881/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/8881/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/8881/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/c1e00ec88ac3c506f78d1e98fcfcc9a1c8e55a70","head":{"label":"jhu-chang:Fix_Transform","ref":"Fix_Transform","sha":"c1e00ec88ac3c506f78d1e98fcfcc9a1c8e55a70","user":{"login":"jhu-chang","id":10203485,"avatar_url":"https://avatars.githubusercontent.com/u/10203485?v=3","gravatar_id":"","url":"https://api.github.com/users/jhu-chang","html_url":"https://github.com/jhu-chang","followers_url":"https://api.github.com/users/jhu-chang/followers","following_url":"https://api.github.com/users/jhu-chang/following{/other_user}","gists_url":"https://api.github.com/users/jhu-chang/gists{/gist_id}","starred_url":"https://api.github.com/users/jhu-chang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhu-chang/subscriptions","organizations_url":"https://api.github.com/users/jhu-chang/orgs","repos_url":"https://api.github.com/users/jhu-chang/repos","events_url":"https://api.github.com/users/jhu-chang/events{/privacy}","received_events_url":"https://api.github.com/users/jhu-chang/received_events","type":"User","site_admin":false},"repo":{"id":32568939,"name":"spark","full_name":"jhu-chang/spark","owner":{"login":"jhu-chang","id":10203485,"avatar_url":"https://avatars.githubusercontent.com/u/10203485?v=3","gravatar_id":"","url":"https://api.github.com/users/jhu-chang","html_url":"https://github.com/jhu-chang","followers_url":"https://api.github.com/users/jhu-chang/followers","following_url":"https://api.github.com/users/jhu-chang/following{/other_user}","gists_url":"https://api.github.com/users/jhu-chang/gists{/gist_id}","starred_url":"https://api.github.com/users/jhu-chang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jhu-chang/subscriptions","organizations_url":"https://api.github.com/users/jhu-chang/orgs","repos_url":"https://api.github.com/users/jhu-chang/repos","events_url":"https://api.github.com/users/jhu-chang/events{/privacy}","received_events_url":"https://api.github.com/users/jhu-chang/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jhu-chang/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/jhu-chang/spark","forks_url":"https://api.github.com/repos/jhu-chang/spark/forks","keys_url":"https://api.github.com/repos/jhu-chang/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jhu-chang/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jhu-chang/spark/teams","hooks_url":"https://api.github.com/repos/jhu-chang/spark/hooks","issue_events_url":"https://api.github.com/repos/jhu-chang/spark/issues/events{/number}","events_url":"https://api.github.com/repos/jhu-chang/spark/events","assignees_url":"https://api.github.com/repos/jhu-chang/spark/assignees{/user}","branches_url":"https://api.github.com/repos/jhu-chang/spark/branches{/branch}","tags_url":"https://api.github.com/repos/jhu-chang/spark/tags","blobs_url":"https://api.github.com/repos/jhu-chang/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jhu-chang/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jhu-chang/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/jhu-chang/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jhu-chang/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/jhu-chang/spark/languages","stargazers_url":"https://api.github.com/repos/jhu-chang/spark/stargazers","contributors_url":"https://api.github.com/repos/jhu-chang/spark/contributors","subscribers_url":"https://api.github.com/repos/jhu-chang/spark/subscribers","subscription_url":"https://api.github.com/repos/jhu-chang/spark/subscription","commits_url":"https://api.github.com/repos/jhu-chang/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/jhu-chang/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/jhu-chang/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/jhu-chang/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/jhu-chang/spark/contents/{+path}","compare_url":"https://api.github.com/repos/jhu-chang/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jhu-chang/spark/merges","archive_url":"https://api.github.com/repos/jhu-chang/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jhu-chang/spark/downloads","issues_url":"https://api.github.com/repos/jhu-chang/spark/issues{/number}","pulls_url":"https://api.github.com/repos/jhu-chang/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/jhu-chang/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/jhu-chang/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jhu-chang/spark/labels{/name}","releases_url":"https://api.github.com/repos/jhu-chang/spark/releases{/id}","created_at":"2015-03-20T07:19:19Z","updated_at":"2015-03-23T03:04:30Z","pushed_at":"2015-09-23T07:25:33Z","git_url":"git://github.com/jhu-chang/spark.git","ssh_url":"git@github.com:jhu-chang/spark.git","clone_url":"https://github.com/jhu-chang/spark.git","svn_url":"https://github.com/jhu-chang/spark","homepage":null,"size":121328,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"5548a254755bb84edae2768b94ab1816e1b49b91","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-09-23T07:39:14Z","pushed_at":"2015-09-23T07:50:57Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":1625882,"stargazers_count":5520,"watchers_count":5520,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5089,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":334,"forks":5089,"open_issues":334,"watchers":5520,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/8881"},"html":{"href":"https://github.com/apache/spark/pull/8881"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/8881"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/8881/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/8881/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/8881/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/c1e00ec88ac3c506f78d1e98fcfcc9a1c8e55a70"}}}}