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

    https://github.com/apache/spark/pull/7450#discussion_r34918854
  
    --- Diff: python/pyspark/sql/functions.py ---
    @@ -658,23 +658,26 @@ class UserDefinedFunction(object):
     
         .. versionadded:: 1.3
         """
    -    def __init__(self, func, returnType):
    +    def __init__(self, func, returnType, name=None):
             self.func = func
             self.returnType = returnType
             self._broadcast = None
    -        self._judf = self._create_judf()
    +        self._judf = self._create_judf(name)
     
    -    def _create_judf(self):
    -        f = self.func  # put it in closure `func`
    -        func = lambda _, it: map(lambda x: f(*x), it)
    +    def _create_judf(self, name):
    +        f, returnType = self.func, self.returnType  # put them in closure 
`func`
    +        from pyspark.serializers import CloudPickleSerializer
    +        CloudPickleSerializer().dumps(returnType)
    --- End diff --
    
    What is this line doing?  It looks like we're calling it only for 
side-effects.  Is it necessary?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to