Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

CSV serde for hive table

avatar
Expert Contributor

The table however still renders like:

 

"SW-1951","21043","nikhil","Medium","Ready For QA","Feed - Update promotions for Google Merchant Center",3600,NA,"2018-04-21T15:34:12.038+0530"

 

This info is coming in a single column

 

If I set field.delim to ',', It spreads with values in columns but then values are coming in " (quotes) and some of the integer values do not come and appear as NULL.

 

What's the right way to do this

Storage information from DESC formatted for my table:

# Storage Information NULL NULL
34 SerDe Library: org.apache.hadoop.hive.serde2.OpenCSVSerde NULL
35 InputFormat: org.apache.hadoop.mapred.TextInputFormat NULL
36 OutputFormat: org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat NULL
37 Compressed: No NULL
38 Num Buckets: -1 NULL
39 Bucket Columns: [] NULL
40 Sort Columns: [] NULL
41 Storage Desc Params: NULL NULL
42 escapeChar "\""
 
43 separatorChar ,
44 serialization.format 1
1 REPLY 1

avatar
New Contributor

Hi,

 I faced the same issue and I used the below query. The solution is the bold parts of the query

ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES ('separatorChar' = ",",'quoteChar'= "\"", 'escapeChar' = "\\")
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
thanks