How to delete and update a record in Hive

后端 未结 15 1307
梦如初夏
梦如初夏 2020-11-28 19:26

I have installed Hadoop, Hive, Hive JDBC. which are running fine for me. But I still have a problem. How to delete or update a single record using Hive because delete or upd

15条回答
  •  执念已碎
    2020-11-28 20:05

    Recently I was looking to resolve a similar issue, Apache Hive, Hadoop do not support Update/Delete operations. So ? So you have two ways:

    1. Use a backup table: Save the whole table in a backup_table, then truncate your input table, then re-write only the data you are intrested to mantain.
    2. Use Uber Hudi: It's a framework created by Uber to resolve the HDFS limitations including Deletion and Update. You can give a look in this link: https://eng.uber.com/hoodie/

    an example for point 1:

    Create table bck_table like input_table;
    Insert overwrite table bck_table 
        select * from input_table;
    Truncate table input_table;
    Insert overwrite table input_table
        select * from bck_table where id <> 1;
    

    NB: If the input_table is an external table you must follow the following link: How to truncate a partitioned external table in hive?

提交回复
热议问题