{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/4492","labels_url":"https://api.github.com/repos/apache/spark/issues/4492/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/4492/comments","events_url":"https://api.github.com/repos/apache/spark/issues/4492/events","html_url":"https://github.com/apache/spark/pull/4492","id":57121605,"number":4492,"title":"[SPARK-5706] [SQL] Add json schema inferring API","user":{"login":"chenghao-intel","id":2367031,"avatar_url":"https://avatars.githubusercontent.com/u/2367031?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghao-intel","html_url":"https://github.com/chenghao-intel","followers_url":"https://api.github.com/users/chenghao-intel/followers","following_url":"https://api.github.com/users/chenghao-intel/following{/other_user}","gists_url":"https://api.github.com/users/chenghao-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghao-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghao-intel/subscriptions","organizations_url":"https://api.github.com/users/chenghao-intel/orgs","repos_url":"https://api.github.com/users/chenghao-intel/repos","events_url":"https://api.github.com/users/chenghao-intel/events{/privacy}","received_events_url":"https://api.github.com/users/chenghao-intel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-02-10T02:22:30Z","updated_at":"2015-02-11T06:21:22Z","closed_at":"2015-02-11T04:57:12Z","pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/4492","html_url":"https://github.com/apache/spark/pull/4492","diff_url":"https://github.com/apache/spark/pull/4492.diff","patch_url":"https://github.com/apache/spark/pull/4492.patch"},"body":"We need to provide json infer schema API instead of manually writing the json schema.\r\n\r\n```\r\nval completeJsonRecord = \"\"\"{\"struct\":{\"field1\": true, \"field2\": 92233720368547758070},\r\n           \"structWithArrayFields\":{\"field1\":[4, 5, 6], \"field2\":[\"str1\", \"str2\"]},\r\n           \"arrayOfString\":[\"str1\", \"str2\"],\r\n           \"arrayOfInteger\":[1, 2147483647, -2147483648],\r\n           \"arrayOfStruct\":[{\"field1\": true, \"field2\": \"str1\"}, {\"field1\": false}, {\"field3\": null}],\r\n           \"arrayOfArray1\":[[1, 2, 3], [\"str1\", \"str2\"]],\r\n           \"arrayOfArray2\":[[1, 2, 3], [1.1, 2.1, 3.1]]\r\n         }\"\"\"\r\n\r\nval schema = sqlContext.inferJsonSchema(completeJsonRecord)\r\nval jsonDF = sqlContext.jsonFile(\"/user/myjson\", schema)\r\n```"},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/73838797","html_url":"https://github.com/apache/spark/pull/4492#issuecomment-73838797","issue_url":"https://api.github.com/repos/apache/spark/issues/4492","id":73838797,"user":{"login":"chenghao-intel","id":2367031,"avatar_url":"https://avatars.githubusercontent.com/u/2367031?v=3","gravatar_id":"","url":"https://api.github.com/users/chenghao-intel","html_url":"https://github.com/chenghao-intel","followers_url":"https://api.github.com/users/chenghao-intel/followers","following_url":"https://api.github.com/users/chenghao-intel/following{/other_user}","gists_url":"https://api.github.com/users/chenghao-intel/gists{/gist_id}","starred_url":"https://api.github.com/users/chenghao-intel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chenghao-intel/subscriptions","organizations_url":"https://api.github.com/users/chenghao-intel/orgs","repos_url":"https://api.github.com/users/chenghao-intel/repos","events_url":"https://api.github.com/users/chenghao-intel/events{/privacy}","received_events_url":"https://api.github.com/users/chenghao-intel/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T06:21:22Z","updated_at":"2015-02-11T06:21:22Z","body":"Thank you @cjnolet for letting me know this, I will review the code when it's ready."}}