Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/10331#discussion_r48228820
--- 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 --
Actually what the test case I constructed reflected is another separate
bug, which has been fixed in PR #10401.
Discussed with @cloud-fan offline. What he meant was, we should also add
`AssertNotNull` for array types and map types, with which I totally agree, but
I think it would be nice to be added in a separate PR.
---
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]