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

    https://github.com/apache/spark/pull/7301#discussion_r34231785
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/pythonUDFs.scala ---
    @@ -220,6 +214,89 @@ object EvaluatePython {
         // TODO(davies): we could improve this by try to cast the object to 
expected type
         case (c, _) => null
       }
    +
    +
    +  private val module = "pyspark.sql.types"
    +
    +  /**
    +   * Pickler for StructType
    +   */
    +  private class StructTypePickler extends IObjectPickler {
    +
    +    private val cls = classOf[StructType]
    +
    +    def register(): Unit = {
    +      Pickler.registerCustomPickler(cls, this)
    +    }
    +
    +    def pickle(obj: Object, out: OutputStream, pickler: Pickler): Unit = {
    +      out.write(Opcodes.GLOBAL)
    +      out.write((module + "\n" + "_parse_datatype_json_string" + 
"\n").getBytes)
    +      val schema = obj.asInstanceOf[StructType]
    +      pickler.save(schema.json)
    +      out.write(Opcodes.TUPLE1)
    +      out.write(Opcodes.REDUCE)
    +    }
    +  }
    +
    +  /**
    +   * Pickler for InternalRow
    +   */
    +  private class RowPickler extends IObjectPickler {
    +
    +    private val cls = classOf[GenericInternalRowWithSchema]
    +
    +    // register this to Pickler and Unpickler
    +    def register(): Unit = {
    +      Pickler.registerCustomPickler(this.getClass, this)
    +      Pickler.registerCustomPickler(cls, this)
    +    }
    +
    +    def pickle(obj: Object, out: OutputStream, pickler: Pickler): Unit = {
    +      if (obj == this) {
    --- End diff --
    
    I'm not super familiar with how Pyrolite works, so perhaps this question is 
a bit naive, but under which circumstances will we try to serialize 
`RowPickler`?  I see a call to save it down on line 261, `pickler.save(this)`.  
In principle, couldn't we just inline the next two lines where we have the 
`pickler.save(this)`?


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