开发者学堂课程【新电商大数据平台2020最新课程:电商项目之用户关注 DWS 表 SQL 实现】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/640/detail/10544
电商项目之用户关注 DWS 表 SQL 实现
目录:
一、简介
二、创建用户关注表
一、简介
用户关注表需要设备 ID、设备号、设备类型、手机系统、版本号、网络类型等等,主要关注两个字段,一个是关注次数,一个是关注产品次数。
关注次数是针对关注的产品来说,关注了多少次,不需要去重,它只统计当前关注了多少次,点击了多少次就统计多少次。
关注产品次数是需要去除的,产品是不可以关注两次的,一个产品只能关注一次。
在进行统计的时候,一个去除,一个不去除。关注次数不去重,关注产品次数去重。
二、创建用户关注表
insertoverwritetable dws_nshop.dws_nshop_ulog_comment partition(bdp_day="20200321')
select
user_id ,
device_num ,
device_type,
os ,
os_version ,
manufacturer,
carrier ,
network_type,
area_code,
count(target_id) over(partition by target_id)as comment_count,
count(distinct target_id) over(partition by target_id)as comment_target_count
Bdp_day
from dwd_nshop.dwd_actlog_product_comment
where
bdp_day= " 20200321"
进行查询
hive> select * from dws nshop.dws nshop ulog comment limit 10;