title: Spark UDF with dictionary argument fails
body: <p>I have a column (myCol) in a Spark dataframe that has values 1,2 and I want to create a new column with the description of this values like 1-> 'A', 2->'B' etc</p>
  
  <p>I know that this can be done with a join but I tried this because it seems more elegant:</p>
  
  <pre><code>dictionary= { 1:'A' , 2:'B' }
  
  add_descriptions = udf(lambda x , dictionary: dictionary[x] if x in dictionary.keys() else None)
  
  df.withColumn("description",add_descriptions(df.myCol,dictionary))
  </code></pre>
  
  <p>And it fails with error </p>
  
  <blockquote>
  <pre><code>lib/py4j-0.10.4-src.zip/py4j/protocol.py", line 323, in get_return_value
  py4j.protocol.Py4JError: An error occurred while calling z:org.apache.spark.sql.function  s.col. Trace:
  py4j.Py4JException: Method col([class java.util.HashMap]) does not exist
          at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:318)
          at py4j.reflection.ReflectionEngine.getMethod(ReflectionEngine.java:339)
          at py4j.Gateway.invoke(Gateway.java:274)
          at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
          at py4j.commands.CallCommand.execute(CallCommand.java:79)
          at py4j.GatewayConnection.run(GatewayConnection.java:214)
          at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  </blockquote>
  
  <p>Is it not possible to have a user difined function with dictionaries as arguments?</p>