-
- Downloads
[SPARK-21677][SQL] json_tuple throws NullPointException when column is null as string type
## What changes were proposed in this pull request? ``` scala scala> Seq(("""{"Hyukjin": 224, "John": 1225}""")).toDS.selectExpr("json_tuple(value, trim(null))").show() ... java.lang.NullPointerException at ... ``` Currently the `null` field name will throw NullPointException. As a given field name null can't be matched with any field names in json, we just output null as its column value. This PR achieves it by returning a very unlikely column name `__NullFieldName` in evaluation of the field names. ## How was this patch tested? Added unit test. Author: Jen-Ming Chung <jenmingisme@gmail.com> Closes #18930 from jmchung/SPARK-21677.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/jsonExpressions.scala 4 additions, 4 deletions...ache/spark/sql/catalyst/expressions/jsonExpressions.scala
- sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/JsonExpressionsSuite.scala 10 additions, 0 deletions...spark/sql/catalyst/expressions/JsonExpressionsSuite.scala
- sql/core/src/test/resources/sql-tests/inputs/json-functions.sql 6 additions, 0 deletions...re/src/test/resources/sql-tests/inputs/json-functions.sql
- sql/core/src/test/resources/sql-tests/results/json-functions.sql.out 33 additions, 1 deletion...c/test/resources/sql-tests/results/json-functions.sql.out
Loading
Please register or sign in to comment