hive事务得设置

1. 通过命令行方式开启事务,当前session有效

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;
set hive.compactor.initiator.on = true;
set hive.compactor.worker.threads = 1; 

2. 通过配置文件hive-site.xml

<property> 
    <name>hive.support.concurrency</name> 
    <value>true</value>
</property>
<property> 
    <name>hive.txn.manager</name> 
    <value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
</property>

3. 通过UI工具(如Ambari)设置

按照上面的方式之一开启Hive事务后,创建如下的支持事务的分桶表:

create table dim_Product
(
 product_sk int ,
 product_code int ,
 product_name varchar(128),
 product_category varchar(256),
 version varchar(32),
 effective_date date,
 expiry_date date
)
-- 在Hive中只有分桶表支持事务
clustered by (product_sk ) into 8 buckets
-- 设置属性transactional'='true'开启事务支持
stored as orc tblproperties('transactional'='true');

 

posted @ 2023-11-08 19:59  所向披靡zz  阅读(83)  评论(0编辑  收藏  举报