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

    https://github.com/apache/spark/pull/7301#discussion_r34284460
  
    --- 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 --
    
    Ah, makes sense.  Can you add a one-line comment to explain this, e.g. 
something like "we could inline this below but since it's a constant object 
that can benefit from memoization we use picker.save instead".


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