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

    https://github.com/apache/spark/pull/18488#discussion_r134477280
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/JavaTypeInference.scala
 ---
    @@ -345,6 +356,30 @@ object JavaTypeInference {
         }
       }
     
    +  /** Returns a mapping from enum value to int for given enum type */
    +  def enumSerializer[T <: Enum[T]](enum: Class[T]): T => UTF8String = {
    +    assert(enum.isEnum)
    +    inputObject: T =>
    +      UTF8String.fromString(inputObject.name())
    +  }
    +
    +  /** Returns value index for given enum type and value */
    +  def serializeEnumName[T <: Enum[T]](enum: UTF8String, inputObject: T): 
UTF8String = {
    +    
enumSerializer(Utils.classForName(enum.toString).asInstanceOf[Class[T]])(inputObject)
    +  }
    --- End diff --
    
    Utils.classForName delegates to Class.forName, which operates on native 
level, so additional optimizations like caching are not required


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