文章目录
01:其他维度:组织机构
-
目标:实现组织机构维度的设计及构建
-
路径
- step1:需求
- step2:设计
- step3:实现
-
实施
- 需求:实现组织机构维度表的构建,得到每个工程师对应的组织机构信息
- 统计不同服务人员的工单数、核销数等
-
设计
- org_employee:员工信息表【员工id、员工编码、员工名称、用户系统id】
select empid,empcode,empname,userid from org_employee;
- org_empposition:员工岗位信息表【员工id、岗位id】
select empid,positionid from org_empposition;
- org_position:岗位信息表【岗位id、岗位编码、岗位名称、部门id】
select positionid,posicode,posiname,orgid from org_position;
- org_organization:部门信息表【部门id、部门编码、部门名称】
select orgid,orgcode,orgname from org_organization; ```![image-20211010153834323](https://img-blog.csdnimg.cn/img_convert/7d534d40e3b947af31c914cca4d39356.png)
-
实现
- 建维度表
-- 创建组织机构维度表,组织机构人员是经常变动的,所以按照日期分区 create external table if not exists one_make_dws.dim_emporg( empid string comment '人员id' , empcode string comment '人员编码(erp对应的账号id)' , empname string comment '人员姓名' , userid string comment '用户系统id(登录用户名)' , posid string comment '岗位id' , posicode string comment '岗位编码' , posiname string comment '岗位名称' , orgid string comment '部门id' , orgcode string comment '部门编码' , orgname string comment '部门名称' ) comment '组织机构维度表' partitioned by (dt string) stored as orc location '/data/dw/dws/one\_make/dim\_emporg';
- 抽取数据
-- 先根据dwd层的表进行关联,然后分别把数据取出来 insert overwrite table one_make_dws.dim_emporg partition(dt='20210101') select emp.empid as empid , emp.empcode as empcode , emp.empname as empname , emp.userid as userid , pos.positionid as posid , pos.posicode as posicode , pos.posiname as posiname , org.orgid as orgid , org.orgcode as orgcode , org.orgname as orgname from one_make_dwd.org_employee emp left join one_make_dwd.org_empposition emppos on emp.empid = emppos.empid and emp.dt = '20210101' and emppos.dt = '20210101' left join one_make_dwd.org_position pos on emppos.positionid = pos.positionid and pos.dt = '20210101' left join one_make_dwd.org_organization org on pos.orgid = org.orgid and org.dt = '20210101';
-
小结
- 实现组织机构维度的设计及构建
02:其他维度:仓库、物流
-
目标:实现仓库维度、物流维度的构建
-
路径
- step1:仓库维度
- step2:物流维度
-
实施
-
仓库维度
- 建表
-- 仓库维度表 create external table if not exists one_make_dws.dim_warehouse( code string comment '仓库编码' , name string comment '仓库名称' , company_id string comment '所属公司' , company string comment '公司名称' , srv_station_id string comment '所属服务网点ID' , srv_station_name string comment '所属服务网点名称' )comment '仓库维度表' partitioned by (dt string) stored as orc location '/data/dw/dws/one\_make/dim\_warehouse';
- 加载
insert overwrite table one_make_dws.dim_warehouse partition(dt='20210101') select warehouse.code as code , warehouse.name as name , warehouse.company as company_id , cmp.compmay as compmay , station.id as srv_station_id , station.name as srv_station_name from one_make_dwd.ciss_base_warehouse warehouse
-
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
**
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!