其他分享
首页 > 其他分享> > ODPS的TRANS_ARRAY应用

ODPS的TRANS_ARRAY应用

作者:互联网

–qlr拆分
drop table if exists tmp_fcxx_qlr;
create table tmp_fcxx_qlr as
select zl
,qlr_old
,qlr_new
from (
select trans_array(2, ‘;’, zl, qlr, qlr) as (zl, qlr_old, qlr_new)
from dc01_rkk_ml_zcxx_bdcqrxx
where dt = ‘ b d p . s y s t e m . b i z d a t e ′ a n d r e g e x p e x t r a c t ( q l r , ′ ( [ [ : p u n c t : ] ] ) ′ ) = ′ ; ′ u n i o n s e l e c t t r a n s a r r a y ( 2 , ′ , ′ , z l , q l r , q l r ) a s ( z l , q l r o l d , q l r n e w ) f r o m d c 0 1 r k k m l z c x x b d c q r x x w h e r e d t = ′ {bdp.system.bizdate}' and regexp_extract(qlr, '([[:punct:]])') = ';' union select trans_array(2, ',', zl, qlr, qlr) as (zl, qlr_old, qlr_new) from dc01_rkk_ml_zcxx_bdcqrxx where dt = ' bdp.system.bizdate′andregexpe​xtract(qlr,′([[:punct:]])′)=′;′unionselecttransa​rray(2,′,′,zl,qlr,qlr)as(zl,qlro​ld,qlrn​ew)fromdc01r​kkm​lz​cxxb​dcqrxxwheredt=′{bdp.system.bizdate}’
and regexp_extract(qlr, ‘([[:punct:]])’) = ‘,’
union
select trans_array(2, ‘/’, zl, qlr, qlr) as (zl, qlr_old, qlr_new)
from dc01_rkk_ml_zcxx_bdcqrxx
where dt = ‘ b d p . s y s t e m . b i z d a t e ′ a n d r e g e x p e x t r a c t ( q l r , ′ ( [ [ : p u n c t : ] ] ) ′ ) = ′ / ′ u n i o n s e l e c t t r a n s a r r a y ( 2 , ′ 、 ′ , z l , q l r , q l r ) a s ( z l , q l r o l d , q l r n e w ) f r o m d c 0 1 r k k m l z c x x b d c q r x x w h e r e d t = ′ {bdp.system.bizdate}' and regexp_extract(qlr, '([[:punct:]])') = '/' union select trans_array(2, '、', zl, qlr, qlr) as (zl, qlr_old, qlr_new) from dc01_rkk_ml_zcxx_bdcqrxx where dt = ' bdp.system.bizdate′andregexpe​xtract(qlr,′([[:punct:]])′)=′/′unionselecttransa​rray(2,′、′,zl,qlr,qlr)as(zl,qlro​ld,qlrn​ew)fromdc01r​kkm​lz​cxxb​dcqrxxwheredt=′{bdp.system.bizdate}’
and regexp_extract(qlr, ‘([[:punct:]])’) = ‘、’
) t
where qlr_old is not null
;
trans_array (num_keys, separator, key1,key2,…,col1, col2,col3) as (key1,key2,…,col1, col2)
trans_array(2, ‘;’, zl, qlr, qlr) as (zl, qlr_old, qlr_new) – > 2指两列,zl / qlr两列,拆分第3列qlr,最后生成3列表:zl / 老权利人 / 新权利人

标签:zl,old,keys,qlr,bizdate,bdp,ODPS,ARRAY,TRANS
来源: https://blog.csdn.net/RLCxiezhen/article/details/113555794