Hive: How to Handle files which has delimiter in the data file?

Hive: How to Handle files which has delimiter in the data file?



I have the below data that needs to be insert into a hive table. The data has the default delimiter in the file. How to insert into a hive table?


10,Andrew,Man”,”ager,DE,PC
11,Arun,Manager,NJ,PC
12,Harish,Sales,NJ,MAC
13,Robert,Manager,PA,MAC
14,Laura,Engineer,PA,MAC



Thanks!




2 Answers
2



Try using CSV Serde


create table test_table(id int,...)
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde'
WITH SERDEPROPERTIES (
"separatorChar" = ",",
"quoteChar" = "”",
"escapeChar" = "\"
)



change quoteChar based on the data





Used below DDL create table Names( EmployeeID INT, FirstName STRING, Title STRING, State STRING, Laptop STRING ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde' WITH SERDEPROPERTIES ( "separatorChar" = ",", "quoteChar" = "”", "escapeChar" = "\" ) STORED AS TEXTFILE; But ',' is not displayed in the table. "10" "Andrew" "Man ager" "DE" "11" "Arun" "Manager" "NJ" "PC" "12" "Harish" "Sales" "NJ" "MAC" "13" "Robert" "Manager" "PA" "MAC" "14" "Laura" "Engineer" "PA" "MAC"
– Holmes
Aug 30 at 8:28






same query works for me. able to view the commas.
– Saravanan Elumalai
Aug 30 at 10:10



You have two options first you can used "|" (pipe) as delimiter and then insert into a hive table otherwise you have to enclose your data fields in double quotes " ", then use the OpenCSV Serde when creating the DDL for your Hive table. Now you can query the table and Hive will correctly display the data.


"|"


" "



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ