with tmp as (
select '01' as code, 1001 as key ,'政务科技' as value
union all
select '02' as code, 1002 as key ,'政务科技2' as value
union all
select '03' as code, 1003 as key ,'政务科技3' as value
),tmp1 as (
select '01' as code, 1001 as key ,'政务科技' as value
union all
select '02' as code, 1002 as key ,'政务科技' as value
union all
select '03' as code, 10030 as key ,'政务科技3' as value
)
select
sort_array(split(substr(cast(map1 as string),2,length(cast(map1 as string))-2),','))new_map1
,sort_array(split(substr(cast(map2 as string),2,length(cast(map2 as string))-2),',')) new_map2
,case when sort_array(split(substr(cast(map1 as string),2,length(cast(map1 as string))-2),',')) <>
sort_array(split(substr(cast(map2 as string),2,length(cast(map2 as string))-2),',')) then '增量'
else '同步数据(一样数据)' end update_data
-- code,map1,map2
from (
select
tmp1.code
,collect_set(to_json(MAP(tmp.key,tmp.value))) map1
,collect_set(to_json(MAP(tmp1.key,tmp1.value)) ) map2
from tmp
left join tmp1 on tmp.code=tmp1.code
group by
tmp1.code
) t