hadoop - 如何将多个文件加载到配置单元中的表中?

标签 hadoop hive

有一个目录包含多个待分析的文件,例如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.

Language Manual DML-Loading files into tables

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/

相关文章:

python - 在 Python 中运行 Hive 查询?

java - hadoop运行程序出错?

java - 将 Hadoop MapReduce 输出写入 2 个平面文件

hadoop - 启动 Impala 的问题

xml - 当我添加hive-site.xml时,Hive Shell无法打开

java - Spark 失败,出现 java.lang.OutOfMemoryError : GC overhead limit exceeded?

join - 将MapReduce结果与数据结合

date - Hive - 如何跟踪和更新 Hive 中增量表的上次修改日期?

java - 当 hive.execution.engine 值其 tez 时出现 NoSuchMethodError

hadoop - 从表中创建 json