So I have a main table in Hive, it will store all my data.
I want to be able to load a incremental data update about every month with a large amount of data couple billion rows. There will be new data as well as updated entries.
What is the best way to approach this, I know Hive recently upgrade and supports update/insert/delete.
What I've been thinking is to somehow find the entries that will be updated and remove them from the main table and then just insert the new incremental update. However after trying this, the inserts are very fast, but the deletes are very slow.
The other way is to do something using the update statement to match the key values from the main table and the incremental update and update their fields. I haven't tried this yet. This also sounds painfully slow since Hive would have to update each entry 1 by 1.
Anyone got any ideas as to how to do this most efficiently and effectively ?? I'm pretty new to Hive and databases in general.
If you cannot update in ACID mode using
MERGE
then it's possible to update using FULL OUTER JOIN. To find all entries that will be updated you need to join increment data with old data:It's possible to optimize this by restricting partitions in target_data that will be overwritten and joined.
Also if you want to update all columns with new data, you can apply this solution with
UNION ALL+row_number()
: https://stackoverflow.com/a/44755825/2700344