1、创建表:
create table users2(id int,name string)clustered by (id) into 1 buckets stored as
orc tblproperties('transactional'='true');
2、插入数据
insert into users2(1,'ZHANGSAN'),(2,'LISI');
3、更新数据
update users2 set name='zhangsan2' where id=1;
报错:
FAILED: SemanticException [Error 10294]: Attempt to do update or delete using transaction manager that does not support these operations.
4、更改设置:
客户端:
set hive.support.concurrency = true;
set hive.enforce.bucketing = true ;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.txn.manager= org.apache.hadoop.hive.ql.lockmgr.DbTxnManager;
服务器端:
更改hive-site.xml,增加如下属性:
<property>
<name>hive.compactor.initiator.on</name>
<value>true</value>
</property>
<property>
<name>hive.compactor.worker.threads</name>
<value>1</value>
</property>
5、退出hive客户端,重新进入
6、执行更新操作
7、删除操作
delete from users2 where id=1;
本文介绍如何在Hive中启用事务支持,并通过具体步骤演示如何创建支持事务的表、进行数据插入、更新和删除操作。文章还详细说明了在遇到特定错误时如何调整Hive的配置。
2万+

被折叠的 条评论
为什么被折叠?



