Hive和MapReduce将多级子目录作为输入

原创
2016/04/22 11:47
阅读数 3.9K

默认在hive中,输入的数据只能有一级,比如

create external table if not exists test(id string, name string) row format delimited fields terminated by ',' location '/stb/test'

那么只能加载test目录下的数据,比如test/11.log,test/22.log。不能加载test/11/11.log,test/22/22.log。

所以在hive中,需要设置使得能迭代加载目录。设置如下2个属性

set hive.mapred.supports.subdirectories=true;

set mapreduce.input.fileinputformat.input.dir.recursive=true;

这样就可以迭代加载子目录的数据了。

因为hive底层还是mapreduce。所以mapreduce如果想要迭代加载子目录的属性,也需要设置如下属性:

mapreduce.input.fileinputformat.input.dir.recursive=true

参考:MapReduce和Hive支持递归子目录作为输入

 

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
3 收藏
1
分享
返回顶部
顶部