Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
452 views
in Technique[技术] by (71.8m points)

hadoop - 如何从HIVE(SQL)的列中删除文本(How do I remove text from columns in HIVE (sql))

I am trying to import data from a CSV file (latlong.csv) and I want to remove all of the quotes from my columns.

(我正在尝试从CSV文件(latlong.csv)导入数据,并且想从列中删除所有引号。)

Please Refer to first image.

(请参考第一张图片。)

First image

(第一张图片)

This is the code I used to import the data

(这是我用来导入数据的代码)

CREATE TABLE IF NOT EXISTS latlong
    (COUNTRY String, ALPHA2 String, ALPHA3 String, NUMERICCODE String,
    LATITUDE String, LONGITUDE String)
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ','
    LINES TERMINATED BY '
'
    STORED AS TEXTFILE
    tblproperties("skip.header.line.count"="1");

LOAD DATA LOCAL INPATH '/tmp/project2/latlong.csv' INTO TABLE latlong; 

I tried to use the command below but I get an error.

(我尝试使用下面的命令,但出现错误。)

Error saying I can only insert into the table and not update it (i think).

(错误说我只能插入表中而不能更新它(我认为)。)

Update latlong set country = replace(country, '"', '')

error message

(错误信息)

  ask by Alex translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

Please log in or register to reply this article.

OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...