title: How can I insert a key-value pair into a hive map?
body: <p>Based on the following <a href="https://cwiki.apache.org/confluence/display/Hive/Tutorial" rel="noreferrer">tutorial</a>, Hive has a map type. However, there does not seem to be a documented way to insert a new key-value pair into a Hive map, via a <code>SELECT</code> with some UDF or built-in function. Is this possible?</p>
  
  <p>As a clarification, suppose I have a table called <code>foo</code> with a single column, typed <code>map</code>, named <code>column_containing_map</code>.</p>
  
  <p>Now I want to create a new table that also has one column, typed <code>map</code>, but I want each map (which is contained within a single column) to have an additional key-value pair.</p>
  
  <p>A query might look like this:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS bar AS
  SELECT ADD_TO_MAP(column_containing_map, "NewKey", "NewValue") 
  FROM foo;
  </code></pre>
  
  <p>Then the table <code>bar</code> would contain the same maps as table <code>foo</code> except each map in <code>bar</code> would have an additional key-value pair.</p>