title: How to refer a map column in a spark-sql query?
body: <pre><code>scala&gt; val map1 = spark.sql(&quot;select map('p1', 's1', 'p2', 's2')&quot;)
  </code></pre>
  <p>map1: org.apache.spark.sql.DataFrame = [map(p1, s1, p2, s2): map&lt;string,string&gt;]</p>
  <pre><code>scala&gt; map1.show()
  
  +--------------------+
  | map(p1, s1, p2, s2)|
  +--------------------+
  |[p1 -&gt; s1, p2 -&gt; s2]|
  +--------------------+
  scala&gt; spark.sql(&quot;select element_at(map1, 'p1')&quot;)
  </code></pre>
  <blockquote>
  <p>org.apache.spark.sql.AnalysisException: cannot resolve '<code>map1</code>' given
  input columns: []; line 1 pos 18; 'Project
  [unresolvedalias('element_at('map1, p1), None)]</p>
  </blockquote>
  <p>How can we reuse the dataframe map1 in second sql query?</p>