开发者学堂课程【新电商大数据平台2020最新课程:电商项目之 DWD 用户产品关注表 SQL 实现】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/640/detail/10531
电商项目之 DWD 用户产品关注表 SQL 实现
目录:
一、创建用户产品关注表
二、运行用户产品关注表
一、 创建用户产品关注表
//先创建一个临时表,
with log_attend as(
Select
//与前面字段一样
customer_id,
device_num,
device_type,
os,
os_version,
manufacturer,
carrier ,
network_type,
area_code,
get_json_objtect(extinfo,'$.target_action')as target_action, get_json_objtect(extinfo,'$.target_id')as target_id,
//将 action 改成 id
ct,
bdp_day
from ods_nshop.ods_nshop_01_useractlog
//条件
where
bdp_day='20200321'
and
action='05'
and
event_type='02'
select
from log_attend
二、运行用户产品关注表
写完后运行
运行后出现:
AILED:SemanticException[Error 10011]: Invalid function get json objtect,
即没有找到 get json objtect,将 objtect 改成 object,
现在的 target_action 既包括01又包括02还包括03,还需要继续判断,
判断操作如下:
select
customer id,
device_num ,
device_type,
os
os_version ,
manufacturer,
carrier ,
network_type,
area_code,
target_id,
ct,
bdp_day
from log_attend where
target_action='01"
这是取出来的是所有的关注数据,两个代码一起运行,在两个代码之间插入:
insert overwrite table dwd_nshop.dwd_actlog_product_comment partition(bdp_day)
运行,运行结果如下:
有数据即可