數倉項目實戰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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章