explode

更新时间:2022-11-27 03:57:04 阅读: 评论:0


2022年11月27日发(作者:奥斯卡颁奖典礼音乐)

使⽤Hive炸裂函数explode(mapstring,string)宽表转⾼表

Hive炸裂函数explode(map)宽表转⾼表SQL:

lect

slice_id,

ur_id,

shop_id,

'ur_stats_public'astable_code,

explode(kv)as(field_code,field_value)

from

(lect

ur_id,

-1asshop_id,

abs(hash(ur_id)%20000)asslice_id,

map(

'residence_city_name',residence_city_name,

'residence_city_level',residence_city_level,

'gender',gender,

'age',age,

'activeness_level',activeness_level,

'consuming_level',consuming_level,

'pay_amt_td_level',pay_amt_td_level,

'old_ecom_ur',old_ecom_ur

)askv

fromecom__mapping_table_13_93

wheredate=max_pt('ecom__mapping_table_13_93'))a;

explode()explode()::UsageExamplesUsageExamples

raexplode(array)

lectexplode(array('A','B','C'));

lectexplode(array('A','B','C'))ascol;

lecttf.*from(lect0)tlateralviewexplode(array('A','B','C'))tf;

lecttf.*from(lect0)tlateralviewexplode(array('A','B','C'))tfascol;

de(maexplode(map)

lectexplode(map('A',10,'B',20,'C',30));

lectexplode(map('A',10,'B',20,'C',30))as(key,value);

lecttf.*from(lect0)tlateralviewexplode(map('A',10,'B',20,'C',30))tf;

lecttf.*from(lect0)tlateralviewexplode(map('A',10,'B',20,'C',30))tfaskey,value;

poxplode(array)

lectpoxplode(array('A','B','C'));

lectpoxplode(array('A','B','C'))as(pos,val);

lecttf.*from(lect0)tlateralviewpoxplode(array('A','B','C'))tf;

lecttf.*from(lect0)tlateralviewpoxplode(array('A','B','C'))tfaspos,val;

inline(arrayofstructs)

lectinline(array(struct('A',10,date'2015-01-01'),struct('B',20,date'2016-02-02')));

lectinline(array(struct('A',10,date'2015-01-01'),struct('B',20,date'2016-02-02')))as(col1,col2,col3);

lecttf.*from(lect0)tlateralviewinline(array(struct('A',10,date'2015-01-01'),struct('B',20,date'2016-02-02')))tf;

lecttf.*from(lect0)tlateralviewinline(array(struct('A',10,date'2015-01-01'),struct('B',20,date'2016-02-02')))tfascol1,col2,col3;

stack(values)

lectstack(2,'A',10,date'2015-01-01','B',20,date'2016-01-01');

lectstack(2,'A',10,date'2015-01-01','B',20,date'2016-01-01')as(col0,col1,col2);

lecttf.*from(lect0)tlateralviewstack(2,'A',10,date'2015-01-01','B',20,date'2016-01-01')tf;

lecttf.*from(lect0)tlateralviewstack(2,'A',10,date'2015-01-01','B',20,date'2016-01-01')tfascol0,col1,col2;

Usingthesyntax"SELECTudtf(col)AScolAlias..."hasafewlimitations:

NootherexpressionsareallowedinSELECT

SELECTpageid,explode(adid_list)ASmyCol...isnotsupported

UDTF'scan'tbenested

SELECTexplode(explode(adid_list))ASmyCol...isnotsupported

GROUPBY/CLUSTERBY/DISTRIBUTEBY/SORTBYisnotsupported

SELECTexplode(adid_list)ASmyCol...GROUPBYmyColisnotsupported

PleaeLanguageManualLateralViewforanalternativesyntaxthatdoesnothavethelimitations.

AlsoeWritingUDTFsifyouwanttocreateacustomUDTF.

参考资料

本文发布于:2022-11-27 03:57:04,感谢您对本站的认可!

本文链接:http://www.wtabcd.cn/fanwen/fan/90/28621.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:explode
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图