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

    https://github.com/apache/spark/pull/10331#discussion_r48216083
  
    --- Diff: sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala 
---
    @@ -515,12 +516,44 @@ class DatasetSuite extends QueryTest with 
SharedSQLContext {
         }
         assert(e.getMessage.contains("cannot resolve 'c' given input columns 
a, b"), e.getMessage)
       }
    +
    +  test("runtime nullability check") {
    +    val schema = StructType(Seq(
    +      StructField("f", StructType(Seq(
    +        StructField("a", StringType, nullable = true),
    +        StructField("b", IntegerType, nullable = false)
    +      )), nullable = true)
    +    ))
    +
    +    def buildDataset(rows: Row*): Dataset[NestedStruct] = {
    +      val rowRDD = sqlContext.sparkContext.parallelize(rows)
    +      sqlContext.createDataFrame(rowRDD, schema).as[NestedStruct]
    +    }
    +
    +    checkAnswer(
    +      buildDataset(Row(Row("hello", 1))),
    +      NestedStruct(ClassData("hello", 1))
    +    )
    +
    +    // Shouldn't throw runtime exception when parent object (`ClassData`) 
is null
    --- End diff --
    
    My concern is: if the parent is null, we should shortcut the execution to 
return null directly, instead of going into the field and trigger the null 
check. However, looks like we only do this shortcut for product type by 
`If(IsNull...)`, we may also need to handle array type and map type.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to