【问题标题】:Outputting hive table to HDFS as a single file将配置单元表作为单个文件输出到 HDFS
【发布时间】:2020-02-01 23:59:29
【问题描述】:

我正在尝试将我在 hive 中的表的内容作为单个 csv 文件输出到 hdfs,但是当我运行下面的代码时,它会将其拆分为 5 个单独的文件,每个文件约为 500mb。在将结果输出为单个 csv 文件方面,我是否遗漏了什么?

set hive.execution.engine=tez;
set hive.merge.tezfiles=true;
INSERT OVERWRITE DIRECTORY  "/dl/folder_name"
row format delimited fields terminated by ','
select * from schema.mytable;

【问题讨论】:

标签: hive hdfs


【解决方案1】:

在您的选择查询中添加orderby 子句,然后Hive 将强制运行single reducer,这将只在HDFS 目录中创建一个文件。

INSERT OVERWRITE DIRECTORY  "/dl/folder_name"
row format delimited fields terminated by ','
select * from schema.mytable order by <col_name>;

注意:

如果输出中的number of rows 太大,single reducer 可能需要很长时间才能完成。

【讨论】:

    猜你喜欢
    • 2017-11-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多