开发者学堂课程【新电商大数据平台2020最新课程:电商项目之广告投放数据表 SQL(上)】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/640/detail/10537
电商项目之广告投放数据表 SQL(上)
目录:
一、广告投放数据表
二、营销活动主题——广告投放数据表
一、广告投放数据表【DWD】
Customer_id:用户 ID
(ods_nshop.ods_nshop_02_customer ods_nshop.ods_nshop_01_releasedatas,dim_nshop.dim_pub_page,dim_nshop.dim_pub_product)这两个表主要是找到对应的维表数据。
使用创建临时表的方式,让用户的基本信息与投放数据所需要的字段拿出来。
createexternaltableifnotexists dwd_nshop.dwd_nshop_releasedatas
customer_id Istring comment "用户id" ,
device_num string comment '设备号",
device_type string comment‘设备类型" ,
os string comment‘手机系统",
os_version string comment'手机系统版本',
manufacturer string comment"手机制造商',
area_code string comment "地区编码',
release_sid string comment'投放请求id",
release_ip string comment '投放方ip",
release_session string comment ‘投放会话id" ,
release_sources string comment‘投放渠道",
release_category string comment"投放浏览产品分类",
release_product string comment '投放浏览产品",
release_product_page string comment '投放浏览产品页"
ct bigint comment "创建时间"
partitioned by (bdp_day string)
stored as parquet
location '/data/nshop/dwd/release/dwd_nshop_releasedatas/"
二、营销活动主题——广告投放数据表
首先先把用户基本信息表和投放数据表 join,取到里面相应的信息,如果想拿到投放数据表和用户基本信息表里面的ID,不能去拿 ID 进行 join,投放数据是外部合作的数据,两个 ID 收取的数据可能不一样,它们之间唯一的标志编码,用户的标识编码是设备。
with tbrelease as(
Select(查询需要的字段)
c.customer id,
r .device_ num,
r .device_ type,
r.os ,
r.os_ version,
r .manufacturer ,
r.area_ code,
r.release_ sid,
parse_url (concat("http://127.0.0.1:8088/release?",'',r.release_ params), 'QUERY' , ip')as
release_ ip
r.release_ session,
r.release_ sources,
parse_url(concat("http://127.0.0.1: 8088/release?" , ,r.release_ params), 'QUERY', ' productPage')
as release_ product_ page,
r.ct
from ods. nshop.ods_ nshop_ 01. releasedatas r
join ods_ nshop.ods_ 02_ customer C
on r .device_ _num=C. customer_ device_ num
where
bdp_ day= ' 20200321"
)
http://127.0.0.1:8088/release?
解析的是一个完整的 UL,但是 EXCEL 里面没有完整的 UL,只是UL的一个参数,但是可以拼接成 UL。
parse_ _url("http://127.0.0.1:8088/release?")
变为
parse_url (concat("http://127.0.0.1:8088/release?" ,'' ,r.release_ params), 'QUERY' , ip')as
release_ ip