title: Are there any benefits of registering my udf in pyspark?
body: <p>I have a python function such as:</p>
  
  <pre><code> def blank_as_null(x):
       return when(col(x) != "", col(x)).otherwise(None)
  </code></pre>
  
  <p>I am using this function without running <code>udf(blank_as_null, StringType())</code> as suggested in the documentation: <a href="http://spark.apache.org/docs/2.2.0/api/python/pyspark.sql.html" rel="nofollow noreferrer">http://spark.apache.org/docs/2.2.0/api/python/pyspark.sql.html</a> or in this video: <a href="https://youtu.be/AsW0QzbYVow?t=42m33s" rel="nofollow noreferrer">https://youtu.be/AsW0QzbYVow?t=42m33s</a> (at 42:33 you can see the code calling the <code>udf</code> function)</p>
  
  <p>And then i do something like:</p>
  
  <p><code>myData.withColumn('myColumn', blank_as_null('myColumn'))</code></p>
  
  <p>would there be any benefit of registering the python function first? Under what conditions is the registering beneficial? When it doesn't matter? Or is the registering done automagically under the hood?</p>