Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ object CatalystSerde {
}

def generateObjAttr[T : Encoder]: Attribute = {
AttributeReference("obj", encoderFor[T].deserializer.dataType, nullable = false)()
val enc = encoderFor[T]
val dataType = enc.deserializer.dataType
val nullable = !enc.clsTag.runtimeClass.isPrimitive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now.

AttributeReference("obj", dataType, nullable)()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,15 @@ class DataFrameImplicitsSuite extends QueryTest with SharedSQLContext {
sparkContext.parallelize(1 to 10).map(_.toString).toDF("stringCol"),
(1 to 10).map(i => Row(i.toString)))
}

test("SPARK-19959: df[java.lang.Long].collect includes null throws NullPointerException") {
checkAnswer(sparkContext.parallelize(Seq[java.lang.Integer](0, null, 2), 1).toDF,
Seq(Row(0), Row(null), Row(2)))
checkAnswer(sparkContext.parallelize(Seq[java.lang.Long](0L, null, 2L), 1).toDF,
Seq(Row(0L), Row(null), Row(2L)))
checkAnswer(sparkContext.parallelize(Seq[java.lang.Float](0.0F, null, 2.0F), 1).toDF,
Seq(Row(0.0F), Row(null), Row(2.0F)))
checkAnswer(sparkContext.parallelize(Seq[java.lang.Double](0.0D, null, 2.0D), 1).toDF,
Seq(Row(0.0D), Row(null), Row(2.0D)))
}
}