title: How to pass a constant value to Python UDF?
body: <p>I was thinking if it was possible to create an <code>UDF</code> that receives two arguments a <code>Column</code> and another variable (<code>Object</code>,<code>Dictionary</code>, or any other type), then do some operations and return the result.</p>
  
  <p>Actually, I attempted to do this but I got an exception. Therefore, I was wondering if there was any way to avoid this problem.</p>
  
  <pre><code>df = sqlContext.createDataFrame([("Bonsanto", 20, 2000.00), 
                                   ("Hayek", 60, 3000.00), 
                                   ("Mises", 60, 1000.0)], 
                                  ["name", "age", "balance"])
  
  comparatorUDF = udf(lambda c, n: c == n, BooleanType())
  
  df.where(comparatorUDF(col("name"), "Bonsanto")).show()
  </code></pre>
  
  <p>And I get the following error:</p>
  
  <blockquote>
    <p>AnalysisException: u"cannot resolve 'Bonsanto' given input columns
    name, age, balance;"</p>
  </blockquote>
  
  <p>So it's obvious that the <code>UDF</code> "sees" the <code>string</code> "Bonsanto" as a column name, and actually I'm trying to compare a record value with the second argument.</p>
  
  <p>On the other hand, I know that it's possible to use some operators inside a <code>where</code> clause (but actually I want to know if it is achievable using an <code>UDF</code>), as follows:</p>
  
  <pre><code>df.where(col("name") == "Bonsanto").show()
  
  #+--------+---+-------+
  #|    name|age|balance|
  #+--------+---+-------+
  #|Bonsanto| 20| 2000.0|
  #+--------+---+-------+
  </code></pre>