在经过了ODS层的加载数据、DWD层的解析数据后。这一节将具体分析特定指标,DWS层将对DWD层数据轻度汇总,ADS层将统计数据。
用户每日新增设备表
- 每日新增设备分析。
-
DWS层新建表dws_new_mid_day
hive (gmall)> drop table if exists dws_new_mid_day; create external table dws_new_mid_day ( `mid_id` string COMMENT '设备唯一标识', `user_id` string COMMENT '用户标识', `version_code` string COMMENT '程序版本号', `version_name` string COMMENT '程序版本名', `lang` string COMMENT '系统语言', `source` string COMMENT '渠道号', `os` string COMMENT '安卓系统版本', `area` string COMMENT '区域', `model` string COMMENT '手机型号', `brand` string COMMENT '手机品牌', `sdk_version` string COMMENT 'sdkVersion', `gmail` string COMMENT 'gmail', `height_width` string COMMENT '屏幕宽高', `app_time` string COMMENT '客户端日志产生时的时间', `network` string COMMENT '网络模式', `lng` string COMMENT '经度', `lat` string COMMENT '纬度', `create_date` string comment '创建时间' ) COMMENT '每日新增设备信息' stored as parquet location '/warehouse/gmall/dws/dws_new_mid_day/';
-
插入数据
hive (gmall)> insert into dws_new_mid_day select ud.mid_id, ud.user_id, ud.version_code , ud.version_name , ud.lang , ud.source, ud.os, ud.area, ud.model, ud.brand, ud.sdk_version, ud.gmail, ud.height_width, ud.app_time, ud.network, ud.lng, ud.lat, '2020-02-03' from dws_uv_detail_day ud left join dws_new_mid_day nm on ud.mid_id=nm.mid_id where dt='2020-02-03' and nm.mid_id is null;
-
ADS层统计每日新增设备表ads_new_mid_count
hive (gmall)> drop table if exists ads_new_mid_count; create external table ads_new_mid_count ( `create_date` string comment '创建时间' , `new_mid_count` BIGINT comment '新增设备数量' ) COMMENT '每日新增设备信息数量' row format delimited fields terminated by '\t' location '/warehouse/gmall/ads/ads_new_mid_count/';
-
插入数据
hive (gmall)> insert into ads_new_mid_count select create_date, count(*) from dws_new_mid_day where create_date='2020-02-03' group by create_date;
-
查询结果
hive (gmall)> select * from ads_new_mid_count;
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。