select col_A,col_B,tmp_table.tmp_col
from test_table
lateral view explode(split(col_C,'分隔符')) tmp_table as tmp_col
where partition_name='xxx';
drop table if exists zero_test_01:
create table zero_test_01 (
DEPT_NO string comment'部门编号',
DEPT_TREE string comment'部门层级树',
BENIFIT int comment'利润(万元)'
)
comment '测试-部门利润表'
partitioned by (deal_date string comment '日期分区' )
stored as orc;
alter table zero_test_01 drop if exists partition (DEAL_DATE='20220516');
insert into table zero_test_01 partition (DEAL_DATE='20220516')
select '101','A.A1.101',50;
insert into table zero_test_01 partition (DEAL_DATE='20220516')
select '102','A.A1.102',20;
insert into table zero_test_01 partition (DEAL_DATE='20220516')
select '201','A.A2.201',80;
select tmp_dept_no as DEPT_NO, BENIFIT
from zero_test_01
LATERAL VIEW explode (split(DEPT_TREE, '\\.')) tmp as tmp_dept_no
where DEAL_DATE='20220516';
select tmp_dept_no as DEPT_NO, sum(BENIFIT) as BENIFIT
from zero_test_01
LATERAL VIEW explode (split(DEPT_TREE, '\\.')) tmp as tmp_dept_no
where DEAL_DATE='20220516'
group by tmp_dept_no;
免责申明:
本文系转载,版权归原作者所有,如若侵权请联系我们进行删除!
《数据治理行业实践白皮书》下载地址:https://fs80.cn/4w2atu
《数栈V6.0产品白皮书》下载地址:https://fs80.cn/cw0iw1
想了解或咨询更多有关袋鼠云大数据产品、行业解决方案、客户案例的朋友,浏览袋鼠云官网:https://www.dtstack.com/?src=bbs
同时,欢迎对大数据开源项目有兴趣的同学加入「袋鼠云开源框架钉钉技术群」,交流最新开源技术信息,群号码:30537511,项目地址:https://github.com/DTStack