hive update和delete报错Attempt to do update or delete using transaction manager
转载自(25条消息) hive update和delete报错Attempt to do update or delete using transaction manager_victorzzzz的专栏-CSDN博客
默认在hive中没有默认开启支持单条插入(update)、更新以及删除(delete)操作,需要自己配置。而在默认情况下,当用户如果使用update和delete操作时,会出现如下情况:
hive> update dp set name='beijing' where id=1159;
FAILED: SemanticException [Error 10294]: Attempt to do update or delete using transaction manager that does not support these operations.
以下是开启update与delete功能的步骤梳理:
1、在hive-site.xml文件中,增加如下属性。
<name>hive.support.concurrency</name>
<value>true</value>
<name>hive.enforce.bucketing</name>
<value>true</value>
<name>hive.exec.dynamic.partition.mode</name>
<value>nonstrict</value>
<name>hive.txn.manager</name>
<value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
<name>hive.compactor.initiator.on</name>
<value>true</value>
<name>hive.compactor.worker.threads</name>
<value>1</value>
<name>hive.in.test</name>
<value>true</value>
2、重启hive服务;
3、创建表;
create table student(
id int,
name String,
sex varchar(2),
birthday varchar(10),
major varchar(1)
)clustered by (id) into 2 buckets stored as orc TBLPROPERTIES('transactional'='true');
4、测试update,delete语句
hive> update student set name='beijing' where id=1159;
修改成功。可以成功执行update与delete。频繁的update和delete操作已经违背了hive的初衷。不到万不得已的情况,还是使用增量添加的方式最好。
参考:
开启hive数据表的update delete
http://blog.csdn.net/suijiarui/article/details/51174406
CDH版本hive增加Update、Delete支持
http://www.cnblogs.com/kekukekro/p/6340974.html
hive0.14-insert、update、delete操作测试
http://blog.csdn.net/hi_box/article/details/40820341