大数据开发之Hive篇----使用外部分区表时要注意的事情

直接将数据put到HDFS上,Hive的查询变化

当我们已经使用Hive建立好了一个表的时候,使用desc formatted table_name;可以直接查看到这个表的具体location,如果我们将文件直接放到这个地址上面去,我们在Hive上面理论上面可以直接查询到增加的结果的。
假设我现在Hive上创建了一张外部表

create external table person(id int,name string,age int) partitioned by(create_time string) row format delimited fields terminated by ',' location '/user/table/person';

接着我们在HDFS上导入了这个表在20190321时间的数据

hdfs dfs -mkdir -p /user/table/person/create_time=20190321
hdfs dfs -put /home/test/data/person.dat /user/table/person/create_time=20190321

这个时候你如果直接进行查询是没有办法查询到你添加上去的数据的,我们还需要多一步在Hive上的操作

alter table person add partition(create_time='20190321') location '/home/test/data/person.dat /user/table/person/create_time=20190321';

这里一定要记住要指定你添加数据的那个分区目录在哪里。

发布了118 篇原创文章 · 获赞 16 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_39702831/article/details/88736873
今日推荐