title: lambda or not in PySpark UDF
body: <p>What is the benefit of using lamdba function in PySpark? Here is an example:</p>
  
  <pre><code>def square(x):
      return float(x**2)
  </code></pre>
  
  <p>With lambda, I tried this:</p>
  
  <pre><code>f_square = udf(lambda x: square(x), FloatType())
  result_w_square = result.withColumn('square', f_square(result.x))
  </code></pre>
  
  <p>Without lambda, I tried this:</p>
  
  <pre><code>f_square = udf(square, FloatType())
  result_w_square2 = result.withColumn('square', f_square(result.x))
  </code></pre>
  
  <p>I got the same result. Which approach is better?</p>