Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20694#discussion_r173584330
  
    --- Diff: 
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/JsonExpressionsSuite.scala
 ---
    @@ -680,4 +682,31 @@ class JsonExpressionsSuite extends SparkFunSuite with 
ExpressionEvalHelper {
           )
         }
       }
    +
    +  test("from_json missing fields") {
    +    for (forceJsonNullableSchema <- Seq(false, true)) {
    +      withSQLConf(SQLConf.FROM_JSON_FORCE_NULLABLE_SCHEMA.key -> 
forceJsonNullableSchema.toString) {
    +        val input =
    +          """{
    +            |  "a": 1,
    +            |  "c": "foo"
    +            |}
    +            |"""
    +            .stripMargin
    +        val jsonSchema = new StructType()
    +          .add("a", LongType, nullable = false)
    +          .add("b", StringType, nullable = false)
    +          .add("c", StringType, nullable = false)
    +        val output = InternalRow(1L, null, UTF8String.fromString("foo"))
    +        checkEvaluation(
    +          JsonToStructs(jsonSchema, Map.empty, Literal.create(input, 
StringType), gmtId),
    +          output
    +        )
    +        val schema = JsonToStructs(jsonSchema, Map.empty, 
Literal.create(input, StringType), gmtId)
    +          .dataType
    +        val schemaToCompare = if (forceJsonNullableSchema) 
jsonSchema.asNullable else jsonSchema
    +        assert(schemaToCompare == schema);
    --- End diff --
    
    Nit: `;` is useless. 


---

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

Reply via email to