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

    https://github.com/apache/spark/pull/22749#discussion_r227673675
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/ScalaReflection.scala 
---
    @@ -434,17 +426,34 @@ object ScalaReflection extends ScalaReflection {
        *  * the element type of [[Array]] or [[Seq]]: `array element class: 
"abc.xyz.MyClass"`
        *  * the field of [[Product]]: `field (class: "abc.xyz.MyClass", name: 
"myField")`
        */
    -  def serializerFor[T : TypeTag](inputObject: Expression): 
CreateNamedStruct = {
    -    val tpe = localTypeOf[T]
    +  def serializerForType(tpe: `Type`,
    +      cls: RuntimeClass): Expression = 
ScalaReflection.cleanUpReflectionObjects {
         val clsName = getClassNameFromType(tpe)
         val walkedTypePath = s"""- root class: "$clsName"""" :: Nil
    -    serializerFor(inputObject, tpe, walkedTypePath) match {
    -      case expressions.If(_, _, s: CreateNamedStruct) if 
definedByConstructorParams(tpe) => s
    -      case other => CreateNamedStruct(expressions.Literal("value") :: 
other :: Nil)
    -    }
    +
    +    // The input object to `ExpressionEncoder` is located at first column 
of an row.
    +    val inputObject = BoundReference(0, dataTypeFor(tpe),
    +      nullable = !cls.isPrimitive)
    +
    +    serializerFor(inputObject, tpe, walkedTypePath)
       }
     
    -  /** Helper for extracting internal fields from a case class. */
    +  /**
    +   * Returns an expression for serializing the value of an input 
expression into Spark SQL
    --- End diff --
    
    do we really need to duplicate the doc in this private method?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to