默认在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