如何处理蜂巢中的嵌入式逗号?

时间:2019-01-18 20:15:50

标签: hive create-table

例如,如果我有一个带有三个列的csv文件,

 error processing job
 org.springframework.orm.hibernate3.HibernateQueryException: could not resolve property: EXPIRATION_DATE of: component[type,value] [UPDATE 
 com.some.company.PaymentRequestLink ld SET state='EXPIRED' WHERE extraParameters.EXPIRATION_DATE.value <= ? AND state <> 'PAID']; nested exception is org.hibernate.QueryException: could not resolve property: EXPIRATION_DATE of: component[type,value] [UPDATE com.some.company.PaymentRequestLink ld SET state='EXPIRED' WHERE extraParameters.EXPIRATION_DATE.value <= ? AND state <> 'PAID']

如何在蜂巢中加载此类文件。我尝试了stackoverflow的几篇文章,但是没有用。

我创建了一个外部表:

sno,name,salary
 1,latha, 2000
 2,Bhavish, Chaturvedi, 3000

并将数据加载到其中。 但是完成create external table test( id int, name string, salary int ) fields terminated by '\;' stored as text file; 后,我就把所有select * from table都塞进去了。

1 个答案:

答案 0 :(得分:0)

我认为CSV文件具有列名,那么您必须跳过标题以避免该错误,请执行以下步骤:

第1步:创建表

CREATE TABLE salary (sno INT, name STRING, salary INT)  
row format delimited fields terminated BY ',' stored as textfile  
tblproperties("skip.header.line.count"="1");

第2步:将CSV文件加载到表

load data local inpath 'file path' into table salary;  

第3步:测试记录

select * from salary;