Hive查询输出分隔符 [英] Hive query output delimiter
问题描述
首先,您需要更改您的字段分隔符,而不是你的行分隔符。即,
hive>> CREATE TABLE some_table
(col1 int,
col2 int,
col3 string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY','
STORED AS TEXTFILE;
其次,如果您仍然遇到此问题,可以使用sed更改它。
bash>> hive -e'select * from some_Table'| sed's / [\t] /,/ g'> outputfile.txt
请不要在[\t]中按Control + V,然后按Tab char:
sed's /< Control + V>< TAB character> /,/ g'
I have 2 tables in Hive - first is external, the second one is managed. Managed table is populated from external using INSERT OVERWRITE...SELECT FROM external_table. Both tables are created with row delimited by ','. When I run selects queries into file, the delimiter in result file is Tab, but I need comma. How to change it to comma, I see no properties for that.
First of all, you need to change you field delimiter , not your line delimiter ie.
hive >> CREATE TABLE some_table
(col1 int,
col2 int,
col3 string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
STORED AS TEXTFILE;
Secondly, if you still face this issue, you can simply change it using sed.
bash >> hive -e 'select * from some_Table' | sed 's/[\t]/,/g' > outputfile.txt
Please not that [\t] is to press Control+V and then the tab char:
sed 's/<Control+V><TAB character>/,/g'
这篇关于Hive查询输出分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!