title: Compare two tables in HIVE
body: <p>I have 3 tables in hive:</p>
  
  <ul>
  <li>Control_table, with known data</li>
  <li>New_table, with data to check</li>
  <li>Result_table, table where records with different values in new_table then control_table are inserted to</li>
  </ul>
  
  <p>All three tables have same column names (which I won't actually present for security reasons) and number of columns and those are:</p>
  
  <pre><code>c1, c2, c3, c4, c5, c6, c7
  </code></pre>
  
  <p>Where c1 is acting as primary key.</p>
  
  <p>Now I need to put together SQL query for HIVE to compare two tables (control_table with new_table) and rows which have different values to be moved into result table. Now result table have same number of columns as new_table or control_table. If possible I would like to populate only columns which are actually different.</p>
  
  <p>So example of this would be:</p>
  
  <pre><code>Control_table:  c1  | c2 | c3 | c4 | c5 | c6 | c7 |
  
  With a values:  11  | 22 | 33 | 44 | 55 | 66 | 77 |
  </code></pre>
  
  <hr>
  
  <pre><code>New_table:   c1 | c2 | c3 | c4 | c5 | c6 | c7 |
  
  With values: 11 | 21 | 33 | 44 | 54 | 66 | 87 |
  </code></pre>
  
  <hr>
  
  <p>Compare them and result insert into result_table, so result table would look like this:</p>
  
  <pre><code>Result_table:  c1 | c2 | c3 | c4 | c5 | c6 | c7 |
  
  With values:   11 | 21 | -- | -- | 54 | -- | 87 |
  </code></pre>
  
  <p>So only columns with the actual difference in value would be populated.</p>
  
  <p>Now I am rubbish in the SQL, I tried several approaches and tried to ask question here, but got never good answer, here is link to my previous answer which has also example of the sql:</p>
  
  <p><a href="https://stackoverflow.com/questions/26379409/how-to-compare-two-tables-and-return-rows-with-difference-with-hive">How to compare two tables and return rows with difference with HIVE</a></p>
  
  <p>P.S.: It might be that this is not possible, I'm not sure, as I have no previous experiences with NoSQL.</p>