hive复合数据类型array

create table temp.array_test(
name string,
active_date string,
active_num array<string>)
partitioned by (
dt string)
stored as orc;

create table temp.actvice_array_test(
name string,
active_date string,
active_num array<string>)
partitioned by (
dt string)
stored as orc;

insert overwrite table temp.array_test partition(dt)
select ‘wdx’,’20180312′,array(‘0′,’0′,’0′,’0′),’20180312’;

hive> select name,array(active_num[0],active_num[1],active_num[2],active_num[3]) from temp.array_test;
OK
wdx [“0″,”0″,”0″,”0”]
Time taken: 0.06 seconds, Fetched: 1 row(s)

insert overwrite table temp.actvice_array_test partition(dt)
select
name, active_date,
case when active_date = ‘20180312’ then
array(active_num[1],active_num[2],active_num[3],’1′)
else array(active_num[1],active_num[2],active_num[3],’0′) end,
‘20180312’
from temp.array_test
where dt = ‘20180312’;

hive> select * from temp.actvice_array_test;
OK
wdx 20180312 [“0″,”0″,”0″,”1”] 20180312

    原文作者:AI_leef
    原文地址: https://www.jianshu.com/p/6132d1c7ce0f
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞