{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/39891065","id":39891065,"diff_hunk":"@@ -1159,4 +1159,104 @@ class JsonSuite extends QueryTest with SharedSQLContext with TestJsonData {\n           \"SELECT count(a) FROM test_myjson_with_part where d1 = 1\"), Row(9))\n     })\n   }\n+\n+  // scalastyle:off\n+  test(\"backward compatibility\") {\n+    // This test we make sure our JSON support can read JSON data generated by previous version of Spark\n+    // generated through toJSON method and JSON data source.\n+    // The data is generated by the following program.\n+    // Here are a few notes:\n+    //  - Spark 1.5.0 cannot save timestamp data. So, we manually added timestamp field (col13)\n+    //      in the JSON object.\n+    //  - For Spark before 1.5.1, we do not generate UDTs. So, we manually added the UDT value to\n+    //      JSON objects generated by those Spark versions (col17).\n+    //  - If the type is NullType, we do not write data out.\n+\n+    // Create the schema.\n+    val struct =\n+      StructType(\n+        StructField(\"f1\", FloatType, true) ::\n+          StructField(\"f2\", ArrayType(BooleanType), true) :: Nil)\n+\n+    val dataTypes =\n+      Seq(\n+        StringType, BinaryType, NullType, BooleanType,\n+        ByteType, ShortType, IntegerType, LongType,\n+        FloatType, DoubleType, DecimalType(25, 5), DecimalType(6, 5),\n+        DateType, TimestampType,\n+        ArrayType(IntegerType), MapType(StringType, LongType), struct,\n+        new MyDenseVectorUDT())\n+    val fields = dataTypes.zipWithIndex.map { case (dataType, index) =>\n+        StructField(s\"col$index\", dataType, nullable = true)\n+      }\n+    val schema = StructType(fields)\n+\n+    val constantValues =\n+      Seq(\n+        \"a string in binary\".getBytes(\"UTF-8\"),\n+        null,\n+        true,\n+        1.toByte,\n+        2.toShort,\n+        3,\n+        Long.MaxValue,\n+        0.25.toFloat,\n+        0.75,\n+        new java.math.BigDecimal(s\"1234.23456\"),\n+        new java.math.BigDecimal(s\"1.23456\"),\n+        java.sql.Date.valueOf(\"2015-01-01\"),\n+        java.sql.Timestamp.valueOf(\"2015-01-01 23:50:59.123\"),\n+        Seq(2, 3, 4),\n+        Map(\"a string\" -> 2000L),\n+        Row(4.75.toFloat, Seq(false, true)),\n+        new MyDenseVector(Array(0.25, 2.25, 4.25)))\n+    val data = Row.fromSeq(Seq(\"Spark \" + sqlContext.sparkContext.version) ++ constantValues) :: Nil\n+\n+    // Data generated by previous versions.\n+    val existingJSONData =\n+      \"\"\"{\"col0\":\"Spark 1.2.2\",\"col1\":\"YSBzdHJpbmcgaW4gYmluYXJ5\",\"col3\":true,\"col4\":1,\"col5\":2,\"col6\":3,\"col7\":9223372036854775807,\"col8\":0.25,\"col9\":0.75,\"col10\":1234.23456,\"col11\":1.23456,\"col12\":\"2015-01-01\",\"col13\":\"2015-01-01 23:50:59.123\",\"col14\":[2,3,4],\"col15\":{\"a string\":2000},\"col16\":{\"f1\":4.75,\"f2\":[false,true]},\"col17\":[0.25,2.25,4.25]}\"\"\" ::\n+      \"\"\"{\"col0\":\"Spark 1.3.1\",\"col1\":\"YSBzdHJpbmcgaW4gYmluYXJ5\",\"col3\":true,\"col4\":1,\"col5\":2,\"col6\":3,\"col7\":9223372036854775807,\"col8\":0.25,\"col9\":0.75,\"col10\":1234.23456,\"col11\":1.23456,\"col12\":\"2015-01-01\",\"col13\":\"2015-01-01 23:50:59.123\",\"col14\":[2,3,4],\"col15\":{\"a string\":2000},\"col16\":{\"f1\":4.75,\"f2\":[false,true]},\"col17\":[0.25,2.25,4.25]}\"\"\" ::\n+      \"\"\"{\"col0\":\"Spark 1.3.1\",\"col1\":\"YSBzdHJpbmcgaW4gYmluYXJ5\",\"col3\":true,\"col4\":1,\"col5\":2,\"col6\":3,\"col7\":9223372036854775807,\"col8\":0.25,\"col9\":0.75,\"col10\":1234.23456,\"col11\":1.23456,\"col12\":\"2015-01-01\",\"col13\":\"2015-01-01 23:50:59.123\",\"col14\":[2,3,4],\"col15\":{\"a string\":2000},\"col16\":{\"f1\":4.75,\"f2\":[false,true]},\"col17\":[0.25,2.25,4.25]}\"\"\" ::\n+      \"\"\"{\"col0\":\"Spark 1.4.1\",\"col1\":\"YSBzdHJpbmcgaW4gYmluYXJ5\",\"col3\":true,\"col4\":1,\"col5\":2,\"col6\":3,\"col7\":9223372036854775807,\"col8\":0.25,\"col9\":0.75,\"col10\":1234.23456,\"col11\":1.23456,\"col12\":\"2015-01-01\",\"col13\":\"2015-01-01 23:50:59.123\",\"col14\":[2,3,4],\"col15\":{\"a string\":2000},\"col16\":{\"f1\":4.75,\"f2\":[false,true]},\"col17\":[0.25,2.25,4.25]}\"\"\" ::\n+      \"\"\"{\"col0\":\"Spark 1.4.1\",\"col1\":\"YSBzdHJpbmcgaW4gYmluYXJ5\",\"col3\":true,\"col4\":1,\"col5\":2,\"col6\":3,\"col7\":9223372036854775807,\"col8\":0.25,\"col9\":0.75,\"col10\":1234.23456,\"col11\":1.23456,\"col12\":\"2015-01-01\",\"col13\":\"2015-01-01 23:50:59.123\",\"col14\":[2,3,4],\"col15\":{\"a string\":2000},\"col16\":{\"f1\":4.75,\"f2\":[false,true]},\"col17\":[0.25,2.25,4.25]}\"\"\" ::\n+      \"\"\"{\"col0\":\"Spark 1.5.0\",\"col1\":\"YSBzdHJpbmcgaW4gYmluYXJ5\",\"col3\":true,\"col4\":1,\"col5\":2,\"col6\":3,\"col7\":9223372036854775807,\"col8\":0.25,\"col9\":0.75,\"col10\":1234.23456,\"col11\":1.23456,\"col12\":\"2015-01-01\",\"col13\":\"2015-01-01 23:50:59.123\",\"col14\":[2,3,4],\"col15\":{\"a string\":2000},\"col16\":{\"f1\":4.75,\"f2\":[false,true]},\"col17\":[0.25,2.25,4.25]}\"\"\" ::\n+      \"\"\"{\"col0\":\"Spark 1.5.0\",\"col1\":\"YSBzdHJpbmcgaW4gYmluYXJ5\",\"col3\":true,\"col4\":1,\"col5\":2,\"col6\":3,\"col7\":9223372036854775807,\"col8\":0.25,\"col9\":0.75,\"col10\":1234.23456,\"col11\":1.23456,\"col12\":\"16436\",\"col13\":\"2015-01-01 23:50:59.123\",\"col14\":[2,3,4],\"col15\":{\"a string\":2000},\"col16\":{\"f1\":4.75,\"f2\":[false,true]},\"col17\":[0.25,2.25,4.25]}\"\"\" :: Nil\n+\n+    // Generate data for the current version.\n+    val df = sqlContext.createDataFrame(sqlContext.sparkContext.parallelize(data, 1), schema)\n+    withTempPath { path =>\n+      df.write.format(\"json\").mode(\"overwrite\").save(path.getCanonicalPath)\n+\n+      // df.toJSON will convert internal rows to external rows first and then generate JSON objects.\n+      // While, df.write.format(\"json\") will write internal rows directly.\n+      val allJSON =\n+        existingJSONData ++\n+          df.toJSON.collect() ++\n+          sparkContext.textFile(path.getCanonicalPath).collect()\n+\n+      Utils.deleteRecursively(path)\n+      sparkContext.parallelize(allJSON, 1).saveAsTextFile(path.getCanonicalPath)\n+\n+      // Read data back with the schema specified.\n+      val col0Values =\n+        Seq(\n+          \"Spark 1.2.2\",\n+          \"Spark 1.3.1\",\n+          \"Spark 1.3.1\",\n+          \"Spark 1.4.1\",\n+          \"Spark 1.4.1\",\n+          \"Spark 1.5.0\",\n+          \"Spark 1.5.0\",\n+          \"Spark \" + sqlContext.sparkContext.version,\n+          \"Spark \" + sqlContext.sparkContext.version)\n+      val expectedResult = col0Values.map { v =>\n+        Row.fromSeq(Seq(v) ++ constantValues)\n+      }\n+      checkAnswer(\n+        sqlContext.read.format(\"json\").schema(schema).load(path.getCanonicalPath),\n+          expectedResult","path":"sql/core/src/test/scala/org/apache/spark/sql/execution/datasources/json/JsonSuite.scala","position":108,"original_position":108,"commit_id":"593f2b2fca6da1209742add8b61f4522a5e95778","original_commit_id":"593f2b2fca6da1209742add8b61f4522a5e95778","user":{"login":"liancheng","id":230655,"avatar_url":"https://avatars.githubusercontent.com/u/230655?v=3","gravatar_id":"","url":"https://api.github.com/users/liancheng","html_url":"https://github.com/liancheng","followers_url":"https://api.github.com/users/liancheng/followers","following_url":"https://api.github.com/users/liancheng/following{/other_user}","gists_url":"https://api.github.com/users/liancheng/gists{/gist_id}","starred_url":"https://api.github.com/users/liancheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liancheng/subscriptions","organizations_url":"https://api.github.com/users/liancheng/orgs","repos_url":"https://api.github.com/users/liancheng/repos","events_url":"https://api.github.com/users/liancheng/events{/privacy}","received_events_url":"https://api.github.com/users/liancheng/received_events","type":"User","site_admin":false},"body":"Indentation is off.","created_at":"2015-09-18T19:16:17Z","updated_at":"2015-09-18T19:16:17Z","html_url":"https://github.com/apache/spark/pull/8806#discussion_r39891065","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/8806","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/39891065"},"html":{"href":"https://github.com/apache/spark/pull/8806#discussion_r39891065"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/8806"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/8806","id":45358512,"html_url":"https://github.com/apache/spark/pull/8806","diff_url":"https://github.com/apache/spark/pull/8806.diff","patch_url":"https://github.com/apache/spark/pull/8806.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/8806","number":8806,"state":"open","locked":false,"title":"[SPARK-10495] [SQL] Read date values in JSON data stored by Spark 1.5.0.","user":{"login":"yhuai","id":2072857,"avatar_url":"https://avatars.githubusercontent.com/u/2072857?v=3","gravatar_id":"","url":"https://api.github.com/users/yhuai","html_url":"https://github.com/yhuai","followers_url":"https://api.github.com/users/yhuai/followers","following_url":"https://api.github.com/users/yhuai/following{/other_user}","gists_url":"https://api.github.com/users/yhuai/gists{/gist_id}","starred_url":"https://api.github.com/users/yhuai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yhuai/subscriptions","organizations_url":"https://api.github.com/users/yhuai/orgs","repos_url":"https://api.github.com/users/yhuai/repos","events_url":"https://api.github.com/users/yhuai/events{/privacy}","received_events_url":"https://api.github.com/users/yhuai/received_events","type":"User","site_admin":false},"body":"https://issues.apache.org/jira/browse/SPARK-10681","created_at":"2015-09-18T00:42:14Z","updated_at":"2015-09-18T19:16:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"da2f9278ff27c9ebf2b33ad81a90bc51168af03a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/8806/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/8806/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/8806/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/593f2b2fca6da1209742add8b61f4522a5e95778","head":{"label":"yhuai:SPARK-10495","ref":"SPARK-10495","sha":"593f2b2fca6da1209742add8b61f4522a5e95778","user":{"login":"yhuai","id":2072857,"avatar_url":"https://avatars.githubusercontent.com/u/2072857?v=3","gravatar_id":"","url":"https://api.github.com/users/yhuai","html_url":"https://github.com/yhuai","followers_url":"https://api.github.com/users/yhuai/followers","following_url":"https://api.github.com/users/yhuai/following{/other_user}","gists_url":"https://api.github.com/users/yhuai/gists{/gist_id}","starred_url":"https://api.github.com/users/yhuai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yhuai/subscriptions","organizations_url":"https://api.github.com/users/yhuai/orgs","repos_url":"https://api.github.com/users/yhuai/repos","events_url":"https://api.github.com/users/yhuai/events{/privacy}","received_events_url":"https://api.github.com/users/yhuai/received_events","type":"User","site_admin":false},"repo":{"id":17964653,"name":"spark","full_name":"yhuai/spark","owner":{"login":"yhuai","id":2072857,"avatar_url":"https://avatars.githubusercontent.com/u/2072857?v=3","gravatar_id":"","url":"https://api.github.com/users/yhuai","html_url":"https://github.com/yhuai","followers_url":"https://api.github.com/users/yhuai/followers","following_url":"https://api.github.com/users/yhuai/following{/other_user}","gists_url":"https://api.github.com/users/yhuai/gists{/gist_id}","starred_url":"https://api.github.com/users/yhuai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yhuai/subscriptions","organizations_url":"https://api.github.com/users/yhuai/orgs","repos_url":"https://api.github.com/users/yhuai/repos","events_url":"https://api.github.com/users/yhuai/events{/privacy}","received_events_url":"https://api.github.com/users/yhuai/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yhuai/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/yhuai/spark","forks_url":"https://api.github.com/repos/yhuai/spark/forks","keys_url":"https://api.github.com/repos/yhuai/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yhuai/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yhuai/spark/teams","hooks_url":"https://api.github.com/repos/yhuai/spark/hooks","issue_events_url":"https://api.github.com/repos/yhuai/spark/issues/events{/number}","events_url":"https://api.github.com/repos/yhuai/spark/events","assignees_url":"https://api.github.com/repos/yhuai/spark/assignees{/user}","branches_url":"https://api.github.com/repos/yhuai/spark/branches{/branch}","tags_url":"https://api.github.com/repos/yhuai/spark/tags","blobs_url":"https://api.github.com/repos/yhuai/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yhuai/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yhuai/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/yhuai/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yhuai/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/yhuai/spark/languages","stargazers_url":"https://api.github.com/repos/yhuai/spark/stargazers","contributors_url":"https://api.github.com/repos/yhuai/spark/contributors","subscribers_url":"https://api.github.com/repos/yhuai/spark/subscribers","subscription_url":"https://api.github.com/repos/yhuai/spark/subscription","commits_url":"https://api.github.com/repos/yhuai/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/yhuai/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/yhuai/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/yhuai/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/yhuai/spark/contents/{+path}","compare_url":"https://api.github.com/repos/yhuai/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yhuai/spark/merges","archive_url":"https://api.github.com/repos/yhuai/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yhuai/spark/downloads","issues_url":"https://api.github.com/repos/yhuai/spark/issues{/number}","pulls_url":"https://api.github.com/repos/yhuai/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/yhuai/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/yhuai/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yhuai/spark/labels{/name}","releases_url":"https://api.github.com/repos/yhuai/spark/releases{/id}","created_at":"2014-03-21T01:38:52Z","updated_at":"2015-05-07T05:56:12Z","pushed_at":"2015-09-18T18:55:28Z","git_url":"git://github.com/yhuai/spark.git","ssh_url":"git@github.com:yhuai/spark.git","clone_url":"https://github.com/yhuai/spark.git","svn_url":"https://github.com/yhuai/spark","homepage":null,"size":126116,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"4fbf3328692e876f39ea78494510f9d9c5a53f15","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-18T13:51:01Z","pushed_at":"2015-09-18T19:01:21Z","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":1624181,"stargazers_count":5470,"watchers_count":5470,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":5050,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":346,"forks":5050,"open_issues":346,"watchers":5470,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/8806"},"html":{"href":"https://github.com/apache/spark/pull/8806"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/8806"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/8806/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/8806/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/8806/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/593f2b2fca6da1209742add8b61f4522a5e95778"}}}}