Hive(五) Hive参数与动态分区

 Hive 参数与动态分区

1Hive 参数

1.1 hive 当中的参数、变量,都是以命名空间开头

通过${}方式进行引用,其中 system、env 下的变量必须以前缀开头。

1.2 hive 参数设置方式

1、修改配置文件 ${HIVE_HOME}/conf/hive-site.xml

2、启动 hive cli 时,通过--hiveconf key=value 的方式进行设置

例:hive --hiveconf hive.cli.print.header=true

3、进入 cli 之后,通过使用 set 命令设置

注意:2 和 3 两种方式设置的参数只在当前会话有效。

1.3 hive set 命令

在 hive CLI 控制台可以通过 set 对 hive 中的参数进行查询、设置

set 设置:

set hive.cli.print.header=true;

set 查看

set hive.cli.print.header;查看该参数的值

set;查看 hive 的所有参数。

hive 历史操作命令集

~/.hivehistory

hive 参数初始化配置

当前用户家目录下的.hiverc 文件

如: ~/.hiverc

如果没有,可直接创建该文件,将需要设置的参数写到该文件中,hive 启动运行时,会加载改文件中的配置。

[root@node4 ~]#vim .hiverc
set hive.cli.print.header=true;
[root@node4 ~]#hive
hive>

2 hive 动态分区

开启支持动态分区

set hive.exec.dynamic.partition=true;

默认:true

set hive.exec.dynamic.partition.mode=nostrict;

默认:strict 严格模式

(比如订单表以秒为单位创建分区,将会导致特别多的分区,严格模式一般不允许,但是非严格模式允许)。

nostrict:非严格模式

案例演示:

创建原始数据表

create table person21(
id int,
name string,
age int,
gender string,
likes array<string>,
address map<string,string>
)
row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':';

load data local inpath '/root/data/person21.txt' into table person21;

create table person22(
id int,
name string,
likes array<string>,
address map<string,string>
)
partitioned by(age int,gender string)
row format delimited
fields terminated by ','
collection items terminated by '-'
map keys terminated by ':';

加载数据

from person21
insert overwrite table person22 partition(age, gender)
select id, name,likes, address,age, gender distribute by age, gender;

或简写为:

from person21
insert overwrite table person22 partition(age, gender)
select id, name,likes, address,age, gender;

注意:分区字段一定要写到最后面,否则容易出错。

show partitions person22;#查询某表上的 分区

相关参数

set hive.exec.max.dynamic.partitions.pernode;

每一个执行 mr 节点上,允许创建的动态分区的最大数量(100)

set hive.exec.max.dynamic.partitions;

所有执行 mr 节点上,允许创建的所有动态分区的最大数量(1000)

set hive.exec.max.created.files;

所有的 mr job 允许创建的文件的最大数量(100000)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

plenilune-望月

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值