使用用户行为宽表作为DWS层数据
2.1 建表语句
drop table if exists ads_user_last_pay; create external table ads_user_last_pay( user_id string comment ‘用户id‘, pay_date string comment ‘最近一次购买时间‘ ) COMMENT ‘用户最近一次购买时间表‘ stored as parquet location ‘/warehouse/gmall/dws/ads_user_last_pay/‘;
2.2 导入数据
-----------------------------需求-每个用户最近一次购买时间----------------------
-----------------------------相关表---------------------
dws_sale_detail_daycount: 每个用户每天的购买的商品明细
dws_user_action(推荐): 每个用户每天的下单,支付明细(去重)
-----------------------------思路-----------------------
-----------------------------SQL------------------------
insert overwrite TABLE ads_user_last_pay
select
user_id,
max(dt)
from dws_user_action
where payment_count>0
GROUP by user_id
大数据实战(五十八):电商数仓(四十一)之系统业务数据仓库(十四)每个用户最近一次购买时间
原文:https://www.cnblogs.com/qiu-hua/p/13548934.html