title: How to check whether key or value exist in Pyspark Map
body: <p>I have a Map column in a spark DF and would like to filter this column on a particular key (i.e. keep the row if the key in the map matches desired value).</p>
  
  <p>For example, my schema is defined as:</p>
  
  <pre><code>df_schema = StructType(
    [StructField('id', StringType()),
     StructField('rank', MapType(StringType(), IntegerType()))]
  )
  </code></pre>
  
  <p>My sample data is:</p>
  
  <pre><code>{ "id": "0981850006", "rank": {"a": 1} }
  </code></pre>
  
  <p>Is there any way to filter my df on rows where "a" is in "rank" without using explode()?</p>
  
  <p>Is there a better schema representation for the given json than what I have defined?</p>