Hive扩展功能(九)--Hive的行级更新操作(Update)

软件环境:

linux系统: CentOS6.7
Hadoop版本: 2.6.5
zookeeper版本: 3.4.8

</br>

主机配置:

一共m1, m2, m3这三部机, 每部主机的用户名都为centos
192.168.179.201: m1 
192.168.179.202: m2 
192.168.179.203: m3 

m1: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Master, Worker
m2: Zookeeper, Namenode, DataNode, ResourceManager, NodeManager, Worker
m3: Zookeeper, DataNode, NodeManager, Worker

资料:

官方资料:
    Update资料  <=>      https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML
    Join资料    <=>      https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Joins
网上参考资料:
    Update资料  <=>      http://www.aboutyun.com/thread-12155-1-1.html

</br>

一.为Hive配置Update功能

1.编辑hive-site.xml文件:
<property>
    <name>hive.optimize.sort.dynamic.partition</name>
    <value>false</value>
</property>
<property>
    <name>hive.support.concurrency</name>
    <value>true</value>
</property>
<property>
    <name>hive.enforce.bucketing</name>
    <value>true</value>
</property>
<property>
    <name>hive.exec.dynamic.partition.mode</name>
    <value>nonstrict</value>
</property>
<property>
    <name>hive.txn.manager</name>
    <value>org.apache.hadoop.hive.ql.lockmgr.DbTxnManager</value>
</property>
<property>
    <name>hive.compactor.initiator.on</name>
    <value>true</value>
</property>
<property>
    <name>hive.compactor.worker.threads</name>
    <value>1</value>
</property>
<property>
    <name>hive.in.test</name>
    <value>true</value>
</property>

</br>

二.Update语法

1.创表语句

Hive对使用Update功能的表有特定的语法要求, 语法要求如下:

  1. 要执行Update的表中, 建表时必须带有buckets(分桶)属性
  2. 要执行Update的表中, 需要指定格式,其余格式目前赞不支持, 如:parquet格式, 目前只支持ORCFileformat和AcidOutputFormat
  3. 要执行Update的表中, 建表时必须指定参数(‘transactional’ = true);
    举例:
create table student (id bigint,name string) clustered by (name) into 2 buckets stored as orc TBLPROPERTIES('transactional'='true');
2.更新语句:
update student set id='444' where name='tom';

</br>
</br>
</br>

    原文作者:咸鱼翻身记
    原文地址: https://www.jianshu.com/p/ed6b7c6e7fc3
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞