开发者

Replace Delimiter when exporting to file from Hive

开发者 https://www.devze.com 2023-03-06 03:43 出处:网络
When doing an INSERT OVERWRITE LOCAL DI开发者_如何转开发RECTORY is it possible to specify the delimiter to use?

When doing an INSERT OVERWRITE LOCAL DI开发者_如何转开发RECTORY is it possible to specify the delimiter to use?

For Columns, Collections, Maps, Arrays... The whole gambit of delimiter uses.

A document or such that shows how to implement would be super best fantastic. :)


A simple way is to use concat and only one field if the default line delimiter \n suits you :

INSERT OVERWRITE LOCAL DIRECTORY 'output'
SELECT concat(coalesce(field1,''),'\;',
        coalesce(field2,''),'\;',
        coalesce(field3,''),'\;',
        coalesce(field4,''))
FROM MyTable;

that way you won't have default \001 field delimiters.


There's a ticket for this on the Hive Jira. See https://issues.apache.org/jira/browse/HIVE-634.


use a query like

INSERT OVERWRITE LOCAL DIRECTORY '/home/sumit/POC/code/UseCase1' select day, " ",
count(distinct(feature)) from Table_Day_Feature group by day order by day;

to insert a " " between the columns

0

精彩评论

暂无评论...
验证码 换一张
取 消