非常棒,只有借助这个str_to_map才能成功插入。
我使用如下:
drop table logbase.user_house_hot_tag;
create table logbase.user_house_hot_tag(
city_id string,
user_id string,
tag_p MAP<string,string>
) partitioned by (l_date string,tag_name string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\001'
MAP KEYS TERMINATED BY ':'
LINES TERMINATED BY '\n';
insert overwrite table logbase.user_house_hot_tag partition(l_date='2018-09-24',tag_name='elevator')
select
NULL city_id,
x.user_id,
str_to_map(concat("1",":",round((elevator_1/elevator_all),3))) as tag_p
from
(
select
user_id,
sum(case when elevator = 1 then elevator*view_nums end) as elevator_1,
sum(view_nums) as elevator_all
from logbase.pc_wap_app_wechat_user_house_tag
where l_date='2018-09-18'
and user_id='1148940'
group by user_id
) x;
|