Values inserted in hive table with double quotes f

2019-05-10 10:40发布

问题:

I am exporting a csv file into hive table. about the csv file : column values are enclosed within double-quotes , seperated by comma .

Sample record from csv

"4","good"
"3","not bad"
"1","very worst"

I created a hive table with the following statement,

create external table currys(review_rating string,review_comment string ) row format fields delimited by ',';

Table created .

now I loaded the data using the command load data local inpath and it was successful. when I query the table,

select * from currys;

The result is :

"4"  "good"
"3"  "not bad"
"1"   "very worst"

instead of

4  good
3  not bad
1  very worst

records are inserted with double-quotes which shouldnt be.

Please let me know how to get rid of this double quote .. any help or guidance is highly appreciated...

Thanks beforehand!

回答1:

Are you using any serde? If so, then you can write a regex command in the SERDE PROPERTIES to remove the quotes.

Or you can use the csv-serde from here and define the quote character.