title: Is there a way to transpose data in Hive?
body: <p>Can data in Hive be transposed? As in, the rows become columns and columns are the rows? If there is no function straight up, is there a way to do it in a couple of steps?</p>
  
  <p>I have a table like this:</p>
  
  <pre><code> | ID   |   Names   |  Proc1   |   Proc2 |  Proc3  |
   | 1    |    A1     |   x      |   b     |  f      |
   | 2    |    B1     |   y      |   c     |  g      |
   | 3    |    C1     |   z      |   d     |  h      |
   | 4    |    D1     |   a      |   e     |  i      |
  </code></pre>
  
  <p>I want it to be like this:</p>
  
  <pre><code> | A1   |   B1   |  C1   |   D1 |  
   | x    |    y   |   z   |   a  |
   | b    |    c   |   d   |   e  |
   | f    |    g   |   h   |   i  |
  </code></pre>
  
  <p>I have been looking up other related questions and they all mention using lateral views and explode, but is there a way to selectively choose columns for lateral(ly) view(ing) and explod(ing)?</p>
  
  <p>Also, what might be the rough process to achieve what I would like to do? Please help me out. Thanks!</p>
  
  <p><strong>Edit</strong>: I have been reading this link: <a href="https://cwiki.apache.org/Hive/languagemanual-lateralview.html" rel="nofollow">https://cwiki.apache.org/Hive/languagemanual-lateralview.html</a> and it shows me half of what I want to achieve. The first example in the link is basically what I'd like except that I don't want the rows to repeat and want them as column names. Any ideas on how to get the data to a form such that if I do an <code>explode</code>, it would result in my desired output, or the other way, ie, <code>explode</code> first to lead to another step that would then lead to my desired output table. Thanks again!</p>