hive - 将配置单元表作为单个文件输出到 HDFS
问题描述
我正在尝试将我在 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;
解决方案
在您的选择查询中添加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>;
笔记:
如果输出中的行数太大,则single reducer
可能需要很长时间才能完成。
推荐阅读
- swift - 如何在 NumberFormatter 中的逗号后显示零
- python - 是否可以构建一个程序来确定另一个 python 程序正在使用哪些库?
- c# - 如何在图表中自动更改 axixY?
- r - R 中的 ggplot2 和 spline() - 错误:`data` 必须是数据框,或其他可被`fortify()` 强制的对象
- jquery - 如何将值转换为具有 2 位小数的货币格式?
- css - bootstrap 或 css 中的这个输入名称是什么?
- hyperledger-fabric - fabric-java-sdk 中的服务发现
- reactjs - react-pdf-js 在 IE11 上抛出未处理的 proise 异常
- visual-studio - 如何为 SSIS 项目设计字体
- android - Google Calendar API 抛出的名称不能为空:null