Skip to content

Commit

Permalink
Fix nullability of NewInstance.
Browse files Browse the repository at this point in the history
  • Loading branch information
ueshin committed Jun 23, 2016
1 parent 093a9fa commit be6ed48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
Expand Up @@ -122,19 +122,10 @@ object RowEncoder {
case t @ ArrayType(et, containsNull) => et match {
case BooleanType | ByteType | ShortType | IntegerType | LongType | FloatType | DoubleType =>
// TODO: validate input type for primitive array.
val nonNullOutput = NewInstance(
NewInstance(
classOf[GenericArrayData],
inputObject :: Nil,
dataType = t,
propagateNull = false)

if (inputObject.nullable) {
If(IsNull(inputObject),
Literal.create(null, inputType),
nonNullOutput)
} else {
nonNullOutput
}
dataType = t)

case _ => MapObjects(
{ element =>
Expand Down
Expand Up @@ -213,7 +213,7 @@ case class NewInstance(
outerPointer: Option[() => AnyRef]) extends Expression with NonSQLExpression {
private val className = cls.getName

override def nullable: Boolean = propagateNull
override def nullable: Boolean = propagateNull && arguments.exists(_.nullable)

override def children: Seq[Expression] = arguments

Expand All @@ -238,7 +238,7 @@ case class NewInstance(
val outer = outerPointer.map(func => Literal.fromObject(func()).genCode(ctx))

var isNull = ev.isNull
val setIsNull = if (propagateNull && arguments.nonEmpty) {
val setIsNull = if (nullable) {
s"final boolean $isNull = ${argGen.map(_.isNull).mkString(" || ")};"
} else {
isNull = "false"
Expand Down

0 comments on commit be6ed48

Please sign in to comment.