我必须从csv文件中的配置单元表导出数据,其中的字段用双引号括起来。
到目前为止,我能够生成一个csv没有引号使用以下查询
INSERT OVERWRITE DIRECTORY '/user/vikas/output'
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
SELECT QUERY
生成的输出如下所示
1,Vikas Saxena,Banking,JL5
但是,我需要输出
"1","Vikas Saxena","Banking","JL5"
我试着把查询改成
INSERT OVERWRITE DIRECTORY '/user/vikas/output'
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ",",
"quoteChar" = "\"",
"escapeChar" = "\\"
)
SELECT QUERY
但它显示错误
Error while compiling statement: FAILED: ParseException line 1:0 cannot recognize input near 'ROW' 'FORMAT' 'SERDE'
1条答案
按热度按时间2ekbmq321#
创建外部表:
然后在该表中选择:
然后,您的csv在/user/vikas/output的磁盘上