gpt4 book ai didi

hadoop - 在Hive中更新和删除

转载 作者:行者123 更新时间:2023-12-02 21:19:30 26 4
gpt4 key购买 nike

我经过“Programming Hive”编程后发现以下内容。

Hive offers no support for rowlevel
inserts, updates, and deletes. Hive doesn’t support transactions.

但是在CDH5上,我可以在表中添加一行。但是更新和删除将错误抛出为“语义错误”。我读到ACID属性可以在配置单元上设置,但不能正常工作。

Question : Can we update and delete a record in hive?

最佳答案

Hive不适用于OLTP,但现在它支持ACID操作,您必须为其更改一些配置。要尝试,请执行以下操作:

    set hive.support.concurrency = true;
set hive.enforce.bucketing = true;
set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode = nonstrict;

ACID交易(插入,更新和删除)
  • 步骤1 create table testTableNew(id int ,name string )
    clustered by (id) into 2 buckets
    stored as orc TBLPROPERTIES('transactional'='true');
  • 步骤2 insert into table testTableNew values (1,'row1'),(2,'row2'),(3,'row3');
  • 步骤3 update testTableNew set name = 'updateRow2' where id = 2;
  • 步骤4 delete from testTableNew where id = 1;
  • 关于hadoop - 在Hive中更新和删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37802264/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com