Hive: Quickly combine two tables into one?

I have two Hive tables of the same structure (schema). What would be an effective SQL query to combine them into one table with the same structure?

Update, this works pretty fast in my case:

CREATE TABLE xy AS SELECT * FROM (SELECT *
FROM x UNION ALL
SELECT *
FROM y) tmp;

+6
source share
2 answers

If you are trying to combine table_A and table_b into one, the easiest way is to use the UNION ALL operator. Here you can find the syntax and use cases - https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Union

+6
source

"union all" is the right solution, but can be costly, resource / time. I would recommend creating a table with two partitions, one for table A and the other for table B. Thus, there is no need to combine (or combine everything). A merged table is available as soon as both sections are filled.

0
source

All Articles