title: Hive - Create map columns type by aggregating values across groups
body: <p>I have a table that looks like this:</p>
  
  <pre><code>|customer|category|room|date|
  -----------------------------
  |1       |   A    | aa | d1 |
  |1       |   A    | bb | d2 |
  |1       |   B    | cc | d3 |
  |1       |   C    | aa | d1 |
  |1       |   C    | bb | d2 |
  |2       |   A    | aa | d3 |
  |2       |   A    | bb | d4 |
  |2       |   C    | bb | d4 |
  |2       |   C    | ee | d5 |
  |3       |   D    | ee | d6 |
  </code></pre>
  
  <p>I want to create two maps out of the table:</p>
  
  <p><strong>1st</strong>. <em>map_customer_room_date</em>: will <em>group by</em> customer and <strong>collect</strong> all different rooms (<strong>key</strong>) and with date (<strong>value</strong>).</p>
  
  <p>I'm using the <code>collect()</code> <a href="https://github.com/klout/brickhouse" rel="nofollow noreferrer"><em>UDF Brickhouse</em></a> function.</p>
  
  <p><em>this can be archived with something similar as:</em></p>
  
  <pre><code>select customer, collect(room,date) as map_customer_room_date
  from table
  group by customer
  </code></pre>
  
  <p><strong>2nd.</strong> <em>map_category_room_date</em> A bit more complicated, consists also of the same map type <code>collect(room, date)</code> and it will contain as keys, all the rooms across ALL categories where for customer X is categories.
  This means that for <em>customer1</em> it will take room <code>ee</code> even though it belongs to <em>customer2</em>. This is because customer1 has category <code>C</code> and this category is also present in customer 2.</p>
  
  <p>The <strong>final table</strong> is grouped by customer and will look like:</p>
  
  <pre><code>|customer| map_customer_room_date  |     map_category_room_date    |
  -------------------------------------------------------------------|
  |   1    |{aa: d1, bb: d2, cc: d3} |{aa: d1, bb: d2, cc: d3,ee: d6}|
  |   2    |{aa: d3, bb: d4, ee: d6} |{aa: d3, bb: d4, ee: d6}       |
  |   3    |{ee: d6}                 |{ee: d6}                       |  
  </code></pre>
  
  <p>I am having issues building the second map and presenting the final table as described.
  Any idea how this can be accomplished?</p>