Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2355#discussion_r17585758
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/hiveUdfs.scala 
---
    @@ -113,30 +113,32 @@ private[hive] case class 
HiveSimpleUdf(functionClassName: String, children: Seq[
           classOf[HiveDecimal], java.lang.Byte.TYPE, classOf[java.lang.Byte],
           classOf[java.sql.Timestamp]
         )
    -    val matchingConstructor = argClass.getConstructors.find { c =>
    +    val matchingConstructors = argClass.getConstructors.filter { c =>
           c.getParameterTypes.size == 1 && 
primitiveClasses.contains(c.getParameterTypes.head)
         }
     
    -    matchingConstructor match {
    -      case Some(constructor) =>
    -        (a: Any) => {
    +    if (matchingConstructors.length == 0) {
    +      (a: Any) => a match {
    +        case wrapper => wrap(wrapper)
    +      }
    +    } else {
    +      (a: Any) => {
    +        if (a == null) {
    +          null
    +        } else {
    +          val constructor = matchingConstructors.find { c =>
    +            c.getParameterTypes.head.getName.equals(a.getClass.getName)
    --- End diff --
    
    Would better to call `Class.getCanonicalName` instead of `Class.getName`.


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