How to create a HIVE table to read semicolon separated values

妖精的绣舞 提交于 2020-12-30 17:21:24

问题


I want to create a HIVE table that will read in semicolon separated values, but my code keeps giving me errors. Does anyone have any suggestions?

CREATE TABLE test_details(Time STRING, Vital STRING, sID STRING) 
PARTITIONED BY(Country STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ';'
STORED AS TEXTFILE;

回答1:


For me nothing worked except this:

FIELDS TERMINATED BY '\u0059'

Edit: After updating Hive:

FIELDS TERMINATED BY '\u003B'

so in full:

CREATE TABLE test_details(Time STRING, Vital STRING, sID STRING) 
PARTITIONED BY(Country STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\u0059'
STORED AS TEXTFILE;



回答2:


The delimiter you are using is the cause for errors. Semi colon is the line terminator for hive which describes completion of hive query.

Use the below modified ddl:

CREATE TABLE test_details(Time STRING, Vital STRING, sID STRING) 
PARTITIONED BY(Country STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\;'
STORED AS TEXTFILE;

This will work for you.




回答3:


Is your text properly sanitized? HIVE natively does not handle quotes in text nicely.

Try using serde with custom separator (i.e. semi-colon in this case).



来源:https://stackoverflow.com/questions/27573863/how-to-create-a-hive-table-to-read-semicolon-separated-values

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!