有一个目录包含多个待分析的文件,例如file1、file2、file3。
我要
load data inpath 'path/to/*' overwrite into table demo
代替
load data inpath 'path/to/file1' overwrite into table demo
load data inpath 'path/to/file2' overwrite into table demo
load data inpath 'path/to/file3' overwrite into table demo
.
然而,它就是行不通。有没有更简单的方法来实现这个?
最佳答案
1.
load data inpath
是一个 HDFS 元数据操作。
它所做的唯一一件事就是将文件从当前位置移动到表位置。
同样,“移动”(与“复制”不同)是一种元数据操作,而不是数据操作。
2.
If the OVERWRITE keyword is used then the contents of the target table (or partition) will be deleted and replaced by the files referred to by filepath; otherwise the files referred by filepath will be added to the table.
3.
load data inpath 'path/to/file1' into table demo;
load data inpath 'path/to/file2' into table demo;
load data inpath 'path/to/file3' into table demo;
或
load data inpath 'path/to/file?' into table demo;
或
dfs -mv path/to/file? ...{path to demo}.../demo
或(来自 bash)
hdfs dfs -mv path/to/file? ...{path to demo}.../demo
关于hadoop - 如何将多个文件加载到配置单元中的表中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42997899/