spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cloud-fan <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12371][SQL] Runtime nullability check f...
Date Tue, 22 Dec 2015 02:22:16 GMT
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message