Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/22237#discussion_r223912044
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/JsonExpressionsSuite.scala
 ---
    @@ -450,21 +456,24 @@ class JsonExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper with
       test("from_json - input=array of single object, schema=struct, 
output=single row") {
         val input = """[{"a": 1}]"""
         val schema = StructType(StructField("a", IntegerType) :: Nil)
    -    val output = InternalRow(1)
    +    val output = InternalRow(null)
         checkEvaluation(JsonToStructs(schema, Map.empty, Literal(input), 
gmtId), output)
       }
     
    -  test("from_json - input=array, schema=struct, output=null") {
    +  test("from_json - input=array, schema=struct, output=single row") {
         val input = """[{"a": 1}, {"a": 2}]"""
    -    val schema = StructType(StructField("a", IntegerType) :: Nil)
    -    val output = null
    -    checkEvaluation(JsonToStructs(schema, Map.empty, Literal(input), 
gmtId), output)
    +    val corrupted = "corrupted"
    +    val schema = new StructType().add("a", IntegerType).add(corrupted, 
StringType)
    +    StructType(StructField("a", IntegerType) :: Nil)
    +    val output = InternalRow(null, UTF8String.fromString(input))
    +    val options = Map("columnNameOfCorruptRecord" -> corrupted)
    +    checkEvaluation(JsonToStructs(schema, options, Literal(input), gmtId), 
output)
       }
     
       test("from_json - input=empty array, schema=struct, output=null") {
    --- End diff --
    
    `output=single row`


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to