{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/29783239","id":29783239,"diff_hunk":"@@ -101,32 +103,87 @@ private[sql] class DefaultSource\n   }\n }\n \n-private[sql] case class JSONRelation(\n-    path: String,\n-    samplingRatio: Double,\n+private[sql] class JSONRelation(\n+    // baseRDD is not immutable with respect to INSERT OVERWRITE\n+    // and so it must be recreated at least as often as the\n+    // underlying inputs are modified. To be safe, a call-by-name\n+    // value (a function) is used instead of a regular value to\n+    // ensure the RDD is recreated on each and every operation.\n+    baseRDD: => RDD[String],","path":"sql/core/src/main/scala/org/apache/spark/sql/json/JSONRelation.scala","position":null,"original_position":51,"commit_id":"26fea314ab12657df6c6397f832d35e681d2e27a","original_commit_id":"e1187eb0e1263fba1fa53f64fad5917649997869","user":{"login":"NathanHowell","id":170829,"avatar_url":"https://avatars.githubusercontent.com/u/170829?v=3","gravatar_id":"","url":"https://api.github.com/users/NathanHowell","html_url":"https://github.com/NathanHowell","followers_url":"https://api.github.com/users/NathanHowell/followers","following_url":"https://api.github.com/users/NathanHowell/following{/other_user}","gists_url":"https://api.github.com/users/NathanHowell/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanHowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanHowell/subscriptions","organizations_url":"https://api.github.com/users/NathanHowell/orgs","repos_url":"https://api.github.com/users/NathanHowell/repos","events_url":"https://api.github.com/users/NathanHowell/events{/privacy}","received_events_url":"https://api.github.com/users/NathanHowell/received_events","type":"User","site_admin":false},"body":"Yes, this is corrected.","created_at":"2015-05-06T17:48:41Z","updated_at":"2015-05-06T17:48:41Z","html_url":"https://github.com/apache/spark/pull/5801#discussion_r29783239","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/5801","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/29783239"},"html":{"href":"https://github.com/apache/spark/pull/5801#discussion_r29783239"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/5801"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/5801","id":34434309,"html_url":"https://github.com/apache/spark/pull/5801","diff_url":"https://github.com/apache/spark/pull/5801.diff","patch_url":"https://github.com/apache/spark/pull/5801.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/5801","number":5801,"state":"open","locked":false,"title":"[SPARK-5938][SPARK-5443][SQL] Improve JsonRDD performance","user":{"login":"NathanHowell","id":170829,"avatar_url":"https://avatars.githubusercontent.com/u/170829?v=3","gravatar_id":"","url":"https://api.github.com/users/NathanHowell","html_url":"https://github.com/NathanHowell","followers_url":"https://api.github.com/users/NathanHowell/followers","following_url":"https://api.github.com/users/NathanHowell/following{/other_user}","gists_url":"https://api.github.com/users/NathanHowell/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanHowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanHowell/subscriptions","organizations_url":"https://api.github.com/users/NathanHowell/orgs","repos_url":"https://api.github.com/users/NathanHowell/repos","events_url":"https://api.github.com/users/NathanHowell/events{/privacy}","received_events_url":"https://api.github.com/users/NathanHowell/received_events","type":"User","site_admin":false},"body":"This patch comprises of a few related pieces of work:\r\n\r\n* Schema inference is performed directly on the JSON token stream\r\n* `String => Row` conversion populate Spark SQL structures without intermediate types\r\n* Projection pushdown is implemented via CatalystScan for DataFrame queries\r\n* Support for the legacy parser by setting `spark.sql.json.useJacksonStreamingAPI` to `false`\r\n\r\nPerformance improvements depend on the schema and queries being executed, but it should be faster across the board. Below are benchmarks using the last.fm Million Song dataset:\r\n\r\n```\r\nCommand                                            | Baseline | Patched\r\n---------------------------------------------------|----------|--------\r\nimport sqlContext.implicits._                      |          |\r\nval df = sqlContext.jsonFile(\"/tmp/lastfm.json\")   |    70.0s |   14.6s\r\ndf.count()                                         |    28.8s |    6.2s\r\ndf.rdd.count()                                     |    35.3s |   21.5s\r\ndf.where($\"artist\" === \"Robert Hood\").collect()    |    28.3s |   16.9s\r\n```\r\n\r\nTo prepare this dataset for benchmarking, follow these steps:\r\n\r\n```\r\n# Fetch the datasets from http://labrosa.ee.columbia.edu/millionsong/lastfm\r\nwget http://labrosa.ee.columbia.edu/millionsong/sites/default/files/lastfm/lastfm_test.zip \\\r\n     http://labrosa.ee.columbia.edu/millionsong/sites/default/files/lastfm/lastfm_train.zip\r\n\r\n# Decompress and combine, pipe through `jq -c` to ensure there is one record per line\r\nunzip -p lastfm_test.zip lastfm_train.zip  | jq -c . > lastfm.json\r\n```\r\n","created_at":"2015-04-30T07:24:11Z","updated_at":"2015-05-06T17:48:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09875659d1ff71ce3689a147d56aa3ec617c693f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/5801/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/5801/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/5801/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/26fea314ab12657df6c6397f832d35e681d2e27a","head":{"label":"NathanHowell:json-performance","ref":"json-performance","sha":"26fea314ab12657df6c6397f832d35e681d2e27a","user":{"login":"NathanHowell","id":170829,"avatar_url":"https://avatars.githubusercontent.com/u/170829?v=3","gravatar_id":"","url":"https://api.github.com/users/NathanHowell","html_url":"https://github.com/NathanHowell","followers_url":"https://api.github.com/users/NathanHowell/followers","following_url":"https://api.github.com/users/NathanHowell/following{/other_user}","gists_url":"https://api.github.com/users/NathanHowell/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanHowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanHowell/subscriptions","organizations_url":"https://api.github.com/users/NathanHowell/orgs","repos_url":"https://api.github.com/users/NathanHowell/repos","events_url":"https://api.github.com/users/NathanHowell/events{/privacy}","received_events_url":"https://api.github.com/users/NathanHowell/received_events","type":"User","site_admin":false},"repo":{"id":18179192,"name":"spark","full_name":"NathanHowell/spark","owner":{"login":"NathanHowell","id":170829,"avatar_url":"https://avatars.githubusercontent.com/u/170829?v=3","gravatar_id":"","url":"https://api.github.com/users/NathanHowell","html_url":"https://github.com/NathanHowell","followers_url":"https://api.github.com/users/NathanHowell/followers","following_url":"https://api.github.com/users/NathanHowell/following{/other_user}","gists_url":"https://api.github.com/users/NathanHowell/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanHowell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanHowell/subscriptions","organizations_url":"https://api.github.com/users/NathanHowell/orgs","repos_url":"https://api.github.com/users/NathanHowell/repos","events_url":"https://api.github.com/users/NathanHowell/events{/privacy}","received_events_url":"https://api.github.com/users/NathanHowell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NathanHowell/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/NathanHowell/spark","forks_url":"https://api.github.com/repos/NathanHowell/spark/forks","keys_url":"https://api.github.com/repos/NathanHowell/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NathanHowell/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NathanHowell/spark/teams","hooks_url":"https://api.github.com/repos/NathanHowell/spark/hooks","issue_events_url":"https://api.github.com/repos/NathanHowell/spark/issues/events{/number}","events_url":"https://api.github.com/repos/NathanHowell/spark/events","assignees_url":"https://api.github.com/repos/NathanHowell/spark/assignees{/user}","branches_url":"https://api.github.com/repos/NathanHowell/spark/branches{/branch}","tags_url":"https://api.github.com/repos/NathanHowell/spark/tags","blobs_url":"https://api.github.com/repos/NathanHowell/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NathanHowell/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NathanHowell/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/NathanHowell/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NathanHowell/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/NathanHowell/spark/languages","stargazers_url":"https://api.github.com/repos/NathanHowell/spark/stargazers","contributors_url":"https://api.github.com/repos/NathanHowell/spark/contributors","subscribers_url":"https://api.github.com/repos/NathanHowell/spark/subscribers","subscription_url":"https://api.github.com/repos/NathanHowell/spark/subscription","commits_url":"https://api.github.com/repos/NathanHowell/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/NathanHowell/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/NathanHowell/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/NathanHowell/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/NathanHowell/spark/contents/{+path}","compare_url":"https://api.github.com/repos/NathanHowell/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NathanHowell/spark/merges","archive_url":"https://api.github.com/repos/NathanHowell/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NathanHowell/spark/downloads","issues_url":"https://api.github.com/repos/NathanHowell/spark/issues{/number}","pulls_url":"https://api.github.com/repos/NathanHowell/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/NathanHowell/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/NathanHowell/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NathanHowell/spark/labels{/name}","releases_url":"https://api.github.com/repos/NathanHowell/spark/releases{/id}","created_at":"2014-03-27T14:43:27Z","updated_at":"2014-03-27T15:13:30Z","pushed_at":"2015-05-06T17:46:44Z","git_url":"git://github.com/NathanHowell/spark.git","ssh_url":"git@github.com:NathanHowell/spark.git","clone_url":"https://github.com/NathanHowell/spark.git","svn_url":"https://github.com/NathanHowell/spark","homepage":null,"size":97417,"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":"c3eb441f5487c9b6476e1d6e2a2d852dcc43b986","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-05-06T17:31:27Z","pushed_at":"2015-05-06T17:48:36Z","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":1600723,"stargazers_count":3873,"watchers_count":3873,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3380,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":309,"forks":3380,"open_issues":309,"watchers":3873,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/5801"},"html":{"href":"https://github.com/apache/spark/pull/5801"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/5801"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/5801/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/5801/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/5801/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/26fea314ab12657df6c6397f832d35e681d2e27a"}}}}