我在文件中有一个数据,如
[street#226 S Wabash Ave,city#Chicago,state#IL]
[street#227 B H Tower,city#San Diego,state#CA]
我使用此代码创建了表格:
create external table if not exists test (
address map<string,string>
)
row format delimited fields terminated by '\;'
COLLECTION ITEMS TERMINATED BY ','
map keys terminated by '#'
;
但是当我正在阅读文件时,我正在解析它:
{"[street#939 W El Camino":null,"city#Chicago":null,"state#IL]":null}
{"[street#415 N Mary Ave":null,"city#Chicago":null,"state#IL]":null}
我该怎么办?
答案 0 :(得分:0)
解决。我首先将数据作为字符串加载到表中,然后使用创建另一个表
select str_to_map(regexp_replace(address,'\\[|\\]',''),',','#') as address from test;