我在HDFS(比如说/用户/ hduser /表1)目录多发性目录和目录下有不同的时间戳像/user/hduser/table1/20160912000000
,/user/hduser/table1/20160912100000
和/user/hduser/table1/20160912121000
阅读使用HIVE外部表
我如何读取多个目录所有通过一个HIVE外部表格在这三个目录下的文件。意味着我必须在HIVE表的LOCATION参数中指定什么。
我在HDFS(比如说/用户/ hduser /表1)目录多发性目录和目录下有不同的时间戳像/user/hduser/table1/20160912000000
,/user/hduser/table1/20160912100000
和/user/hduser/table1/20160912121000
阅读使用HIVE外部表
我如何读取多个目录所有通过一个HIVE外部表格在这三个目录下的文件。意味着我必须在HIVE表的LOCATION参数中指定什么。
试试下面的代码
CREATE TABLE TABLEname (coll INT, coll STRING, coll INT)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ‘,’
LOCATION ‘/user/hduser/table1/*/*’;
我可以用下面的设置来读取嵌套的文件夹。
set hive.mapred.supports.subdirectories=true;
set mapred.input.dir.recursive=true;
我在创建表格时设置了它,然后能够从表格中选择数据。地点关键字我提到如下
LOCATION '/user/hduser/table1/'
,因为我有文件,就像下面这样可不行“/用户/ hduser /表1/201609.12亿/文件1及/用户/ hduser /表1/201609.12亿/文件2”,“/用户/ hduser/table1/20160912100000/file3&/ user/hduser/table1/20160912100000/file4“和”/ user/hduser/table1/20160912121000/file5&/ user/hduser/table1/20160912121000/file6“。我想从file1读取所有文件到file6 –
我已经编辑了答案,假设在/ user/hduser/table1/ –
下会有与同一个表相关的文件否,在使用LOCATION值后仍然没有采集数据如上所述。 –