title: Adding a column which is the result of some formula in Hive
body: <p>I have a table of values. I want another column which, for example, is thrice the first column plus one (or whatever other formula). </p>
  
  <p>If I write something like this:</p>
  
  <pre><code>SELECT item, value, value*3+1 FROM myTable;
  </code></pre>
  
  <p>I get something like this:</p>
  
  <pre><code>A    | 1     | 4
  B    | 2     | 7
  C    | 3     | 10
  </code></pre>
  
  <p>I want to store the third column permanently. Doing this:</p>
  
  <pre><code>ALTER TABLE myTable ADD COLUMN (value*3+1 AS value2 FLOAT);
  </code></pre>
  
  <p>Does not work. However, this does work:</p>
  
  <pre><code>CREATE TABLE myTable2 AS SELECT 
      item, value, value*3+1 AS value2 
      FROM myTable;
  </code></pre>
  
  <p>However, I don't want a new table, I want to insert a column into an existing table. I'm thinking I might need to <code>ADD COLUMN</code> and then <code>INSERT OVERWRITE</code>? Bonus points if your method can use UDFs like avg() or sum(), but I'll take just basic arithmetic for now. </p>
  
  <p>I tried searching and neither <a href="https://stackoverflow.com/questions/12060605/creating-columns-from-results-in-hive">this</a> not <a href="https://stackoverflow.com/questions/209383/select-columns-from-result-set-of-stored-procedure">this</a> answered my question.</p>