轉載自(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