数仓项目实战03:DWS公共汇总粒度事实层

2.2 DWS公共汇总粒度事实层

Hive数据库建库建表:
创建Hive库并进入:

create database if not exists dws_nshop;
use dws_nshop;
2.2.1 用户主题
2.2.2.1 用户启动【DWS】
CREATE external TABLE
IF NOT EXISTS dws_nshop.dws_nshop_ulog_launch (
user_id string COMMENT '用户id',
device_num string COMMENT '设备号',
device_type string COMMENT '设备类型',
os string COMMENT '手机系统',
os_version string COMMENT '手机系统版本',
manufacturer string COMMENT '手机制造商',
carrier string COMMENT '电信运营商',
network_type string COMMENT '网络类型',
area_code string COMMENT '地区编码',
launch_count int COMMENT '启动次数'
) partitioned BY (bdp_day string) stored AS parquet location '/data/nshop/dws/user/dws_nshop_ulog_launch/';

通过对dwd层的用户启动日志表做一个count聚合即可,sql如下:

insert overwrite table dws_nshop.dws_nshop_ulog_launch partition(bdp_day='20200618')
select
user_id,
device_num,
device_type,
os,
os_version,
manufacturer,
car

你可能感兴趣的:(数仓)