Get latest version of table using hive union-all operator <p>I have versioned hive tables containing metrics partitioned by date that I want to join with other versioned hive tables containing different (but related) metrics also partitioned by date. For example: </p> <pre><code>Table A_v1 (exists for day 1) | col1 | col2 | | a1 | b1 | | a2 | b2 | Table A_v2 (exists for day 2, represents metrics derivation algorithm change) | col1 | col2 | | a3 | b3 | | a4 | b4 | Table B_v1 (exists for both day 1 and day 2) | col3 | col4 | | a1 | c1 | | a2 | c2 | | a3 | c3 | | a4 | c4 | </code></pre> <p>I know I can use the UNION ALL Hive operator to basically concatenate tables <code>A_v1</code> and <code>A_v2</code>. What I would like to do however is write something like</p> <pre><code>select a.col1, a.col2, b.col4 from union(A_v1, A_v2) a, B_v1 b where a.col1=b.col3 </code></pre> <p>I know the above syntax is wrong (intended only as a pseudo-code query) but is there some way of accomplishing the same thing in Hive?</p>