title: Querying Spark SQL DataFrame with complex types
body: <p>How Can I query an RDD with complex types such as maps/arrays?
  for example, when I was writing this test code:</p>
  
  <pre><code>case class Test(name: String, map: Map[String, String])
  val map = Map("hello" -&gt; "world", "hey" -&gt; "there")
  val map2 = Map("hello" -&gt; "people", "hey" -&gt; "you")
  val rdd = sc.parallelize(Array(Test("first", map), Test("second", map2)))
  </code></pre>
  
  <p>I thought the syntax would be something like:</p>
  
  <pre><code>sqlContext.sql("SELECT * FROM rdd WHERE map.hello = world")
  </code></pre>
  
  <p>or</p>
  
  <pre><code>sqlContext.sql("SELECT * FROM rdd WHERE map[hello] = world")
  </code></pre>
  
  <p>but I get</p>
  
  <blockquote>
    <p>Can't access nested field in type MapType(StringType,StringType,true)</p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>org.apache.spark.sql.catalyst.errors.package$TreeNodeException: Unresolved attributes</p>
  </blockquote>
  
  <p>respectively.</p>