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