Apache Hive 多级分区数据的加载

1.创建多级分区

创建多级分区:(多层分区目录)

create table xxx(
	.....
)
partitioned by(dept string,sex string)
row format delimited
fields terminated by ',';

load 方式必须保证文件的前几个字段必须和表的字段顺序一致,

保证数据就是这个分区的数据,不推荐

2.insert 方式

insert into table xx partition(deptno='',sex='') select id,name,age from stu_managed where dept='' and sex='';

在创建分区目录的时候,会按照分区字段的顺序创建多级目录的

3.动态分区方式

insert into table xxx partition(分区字段)
select x,x,x,x,x  from xxx;  -- 分区字段要查询出来,而且顺序放在最后

4.一静分区一动分区

静态分区只能是高级分区(第一层分区)

insert into table xxx partition(dept='',sex) select id,name,age,sex from xxx where dept='';

猜你喜欢

转载自blog.csdn.net/qq_33713328/article/details/88688128
今日推荐