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

    https://github.com/apache/spark/pull/10283#discussion_r47488881
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala 
---
    @@ -421,46 +439,75 @@ object ScalaReflection extends ScalaReflection {
         if (!inputObject.dataType.isInstanceOf[ObjectType]) {
           inputObject
         } else {
    +      val className = getClassNameFromType(tpe)
           tpe match {
             case t if t <:< localTypeOf[Option[_]] =>
               val TypeRef(_, _, Seq(optType)) = t
               optType match {
                 // For primitive types we must manually unbox the value of the 
object.
                 case t if t <:< definitions.IntTpe =>
    -              Invoke(
    -                UnwrapOption(ObjectType(classOf[java.lang.Integer]), 
inputObject),
    -                "intValue",
    -                IntegerType)
    +              val unwrapped = 
UnwrapOption(ObjectType(classOf[java.lang.Integer]), inputObject)
    +              expressions.If(
    +                IsNull(unwrapped),
    +                expressions.Literal.create(null, 
silentSchemaFor(optType).dataType),
    +                Invoke(
    +                  unwrapped,
    --- End diff --
    
    If the `unwrapped` is null, the `Invoke` will return null, see 
https://github.com/apache/spark/blob/master/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/objects.scala#L172-L175
    
    I think we don't need this extra `If`, did I miss something here?


---
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