aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorhyukjinkwon <gurwls223@gmail.com>2017-04-02 07:26:49 -0700
committerXiao Li <gatorsmile@gmail.com>2017-04-02 07:26:49 -0700
commitd40cbb861898de881621d5053a468af570d72127 (patch)
treeda279d930abdec88f08f08d4d948fc8fe4b55191 /README.md
parent2287f3d0b85730995bedc489a017de5700d6e1e4 (diff)
downloadspark-d40cbb861898de881621d5053a468af570d72127.tar.gz
spark-d40cbb861898de881621d5053a468af570d72127.tar.bz2
spark-d40cbb861898de881621d5053a468af570d72127.zip
[SPARK-20143][SQL] DataType.fromJson should throw an exception with better message
## What changes were proposed in this pull request? Currently, `DataType.fromJson` throws `scala.MatchError` or `java.util.NoSuchElementException` in some cases when the JSON input is invalid as below: ```scala DataType.fromJson(""""abcd"""") ``` ``` java.util.NoSuchElementException: key not found: abcd at ... ``` ```scala DataType.fromJson("""{"abcd":"a"}""") ``` ``` scala.MatchError: JObject(List((abcd,JString(a)))) (of class org.json4s.JsonAST$JObject) at ... ``` ```scala DataType.fromJson("""{"fields": [{"a":123}], "type": "struct"}""") ``` ``` scala.MatchError: JObject(List((a,JInt(123)))) (of class org.json4s.JsonAST$JObject) at ... ``` After this PR, ```scala DataType.fromJson(""""abcd"""") ``` ``` java.lang.IllegalArgumentException: Failed to convert the JSON string 'abcd' to a data type. at ... ``` ```scala DataType.fromJson("""{"abcd":"a"}""") ``` ``` java.lang.IllegalArgumentException: Failed to convert the JSON string '{"abcd":"a"}' to a data type. at ... ``` ```scala DataType.fromJson("""{"fields": [{"a":123}], "type": "struct"}""") at ... ``` ``` java.lang.IllegalArgumentException: Failed to convert the JSON string '{"a":123}' to a field. ``` ## How was this patch tested? Unit test added in `DataTypeSuite`. Author: hyukjinkwon <gurwls223@gmail.com> Closes #17468 from HyukjinKwon/fromjson_exception.
Diffstat (limited to 'README.md')
0 files changed, 0 insertions, 0 deletions