简体   繁体   English

HADOOP HIVE-是否有用于设置csv输出的命令

[英]HADOOP HIVE - Is there a command for setting csv output

Is there a command line in HIVE that can be used to define the format of the output file to CSV? HIVE中是否存在可用于将输出文件的格式定义为CSV的命令行?

Something similar to the below example? 类似于以下示例吗?

set hive.resultset.use.unique.column.names=false;

EDIT - Added the following for further context 12/18 . 编辑-为进一步的上下文12/18添加了以下内容

A terminal window I'm using has predefined settings for the command line when it runs an 'export' through a script. 我使用的终端窗口在通过脚本运行“导出”时具有命令行的预定义设置。 The following is it's commands: 以下是它的命令:

set hive.metastore.warehouse.dir=/idn/home/user;
set mapred.job.queue.name=root.gmis;
set hive.exec.scratchdir=/axp/hivescratch/user;
set hive.resultset.use.unique.column.names=false;
set hive.cli.print.header=true;
set hive.groupby.orderby.position.alias=true;

Is there another command I could add versus the lengthy strings per below? 与下面的冗长字符串相比,还有其他命令可以添加吗? I'm using in the other hive terminal the following; 我在另一个配置单元终端中使用以下内容; but it's SQL is different(?). 但是它的SQL是不同的(?)。

cloak-hive -e "INSERT OVERWRITE LOCAL DIRECTORY '/adshome/user/VS_PMD' ROW FORMAT DELIMITED FIELDS TERMINATED BY ','

On Apache documentation, https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Writingdataintothefilesystemfromqueries 在Apache文档上,从查询将https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Writingdata放入文件系统

Standard syntax: 标准语法:

 INSERT OVERWRITE [LOCAL] DIRECTORY directory1 [ROW FORMAT row_format] [STORED AS file_format] SELECT ... FROM ... 

INSERT OVERWRITE LOCAL DIRECTORY directory1 
ROW FORMAT DELIMITED 
STORED AS TEXTFILE 
SELECT ... FROM ...;

Maybe some work would be needed on ROW FORMAT to achieve expected result. 可能需要对ROW FORMAT进行一些工作才能达到预期的结果。 Please note also that LOCAL value refers to local filesystem. 另请注意,LOCAL值是指本地文件系统。

You can mention the out put file format to csv refer the following example command. 您可以向csv提及输出文件格式,请参考以下示例命令。 Note that it's same for beeline and hive 请注意,对于蜜蜂和蜂巢来说,这是相同的

beeline -u jdbc:hive2://localhost:10000/default --silent=true --outputformat=csv2 -e "select * from sample_07 limit 10" > out.txt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM