1
j'ai données d'échantillon comme ci-dessous Id (string), delimProperties (string)
ruche str_to_map
1, foo.prop = valeur foo | bar.prop = valeur bar
2, foo2.prop = valeur foo2 | bar2.prop = valeur bar2
Voici mon DML
1)
CREATE TABLE IF NOT EXISTS test_data(Id STRING, delimProperties STRING)<br>
row format delimited <br>
fields terminated by ","<br>
COLLECTION ITEMS TERMINATED BY '|' <br>
map keys terminated by '='<br>
STORED AS textfile;<br>
2)
CREATE TABLE IF NOT EXISTS final_data(Id STRING, delimProperties STRING)
row format delimited
fields terminated by ","
COLLECTION ITEMS TERMINATED BY '|'
map keys terminated by '=';
3)
alter table final_data add columns (properties map<string,string>);
4)
load data local inpath 'file:/c:/data/sample.csv' into table test_data;
5)
insert into table final_data select Id,
str_to_map(delimproperties,'|','=')
from test_data;
6)
Select * from final_data limit 1;
1 {"": "", "": null, ".": Null}
Une idée de ce que je dois faire mal?
quelqu'un a des idées pour expliquer pourquoi cela ne devrait pas travailler? –