hiveconcat_w实现将多⾏记录合并成⼀⾏建表如下:
black swan# 创建商品与促销活动的映射表
hive -e "t mapred.job.queue.name=pms;
educers.max=32;
牛津高中英语>hopkinsduce.tasks=32;
drop table if exists product_promotion;
opposite什么意思
create table product_promotion(product_id bigint, promotion_id String);
inrt into table product_promotion
不正确lect p2.product_id, p2.promotion_id
from pms.promotionv2 p1 inner join pms.promotionv2_main_product_sku p2
on (p1.id=p2.promotion_id)
recitewhere from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss') between p1.start_date d_date;"
数据表的记录如下:
对promotion_id进⾏合并:
lect product_id, concat_ws('_',collect_t(promotion_id)) as promotion_ids from product_promotion group by product_id
执⾏结果:
hive > lect product_id, concat_ws('_',collect_t(promotion_id)) as promotion_ids from product_promotion group by product_id; OK
5112 960024_960025_960026_960027_960028
化妆品专业知识
5113 960043_960044_960045_960046
招聘人员要求有哪些Time taken: 3.116 conds
oltremare
这⾥的collect_t的作⽤是对promotion_id去重,值得注意的是,必须保证promotion_id的类型是string类型