网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
* left join
```
oil_current a left join oil_history b on a.id = b.id
where b.id is null
```
* 当日停用油站:判断当日状态
* 油站设备数量:得到这个油站的所有设备信息,按照油站id分组统计设备个数
+ **数据来源**
- **ciss\_base\_oilstation**:油站信息表
```
select
id os_id --油站id
, name os_name --油站名称
, code os_code --油站编码
, province province_id --油站省份
, city city_id --油站城市
, region county_id --油站区域
, status status_id --油站状态
, customer_classify cstm_type_id --客户分类id
, 1 os_num --油站数量:默认为1
, case when status = 2 then 1 else 0 end invalid_os_num --停用油站数量:1-停用,0-启用
, case when status = 1 then 1 else 0 end valid_os_num --有效油站数量:1-有效,0-无效
from ciss_base_oilstation;
```
- **ciss\_base\_oilstation\_history**:油站历史记录表
* 模拟油站历史记录
```
create table if not exists one_make_dwd.ciss_base_oilstation_history
stored as orc
as select \* from one_make_dwd.ciss_base_oilstation
where dt < '20210102';
```
* 查询历史油站信息
```
--获取当前的油站是否是一个新增油站
select
oil.id
, case when oil.id = his.id then 0 else 1 end current_new_os_num
--今日油站数据表
from one_make_dwd.ciss_base_oilstation oil
--历史油站数据表
left outer join one_make_dwd.ciss_base_oilstation_history his
on oil.id = his.id where oil.dt = '20210101';
```
* **ciss\_base\_device\_detail**:油站设备信息表
```
-- 设备信息表中按照油站id分组聚合设备id:每个油站的设备个数
select
oil.id, count(dev.id) device_num
from one_make_dwd.ciss_base_oilstation oil
left join one_make_dwd.ciss_base_device_detail dev on oil.id = dev.oilstation_id
where oil.dt = '20210101'
group by oil.id;
```
-
小结
- 掌握DWB层油站事实指标表的需求分析
02:油站事实指标构建
-
目标:实现DWB层油站事实指标表的构建
-
实施
- 建表
-- 创建油站事实表 drop table if exists one_make_dwb.fact_oil_station; create table if not exists one_make_dwb.fact_oil_station( os_id string comment '油站id' , os_name string comment '油站名称' , os_code string comment '油站编码' , province_id string comment '省份id' , city_id string comment '城市id' , county_id string comment '县id' , status_id int comment '状态id' , cstm_type_id int comment '客户分类id' , os_num int comment '油站数量 默认为1' , invalid_os_num int comment '已停用油站数量(状态为已停用为1,否则为0)' , valid_os_num int comment '有效油站数量(状态为启用为1,否则为0)' , current_new_os_num int comment '当日新增油站(新增油站为1,老油站为0)' , current_invalid_os_num int comment '当日停用油站(当天停用的油站数量)' , device_num int comment '油站设备数量' ) comment "油站事实表" partitioned by (dt string) stored as orc location '/data/dw/dwb/one\_make/fact\_oil\_station';
- 抽取
insert overwrite table one_make_dwb.fact_oil_station partition(dt = '20210101') select oil.id os_id --油站id , name os_name --油站名称 , code os_code --油站编码 , province province_id --油站省份 , city city_id --油站城市 , region county_id --油站区域 , status status_id --油站状态 , customer_classify cstm_type_id --客户分类id , 1 os_num --油站数量:默认为1 , case when status = 2 then 1 else 0 end invalid_os_num --停用油站数量:1-停用,0-启用 , case when status = 1 then 1 else 0 end valid_os_num --有效油站数量:1-有效,0-无效 , current_new_os_num --当日新增油站数量,1-新增,0-老油站
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上大数据知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新**