假设源表具有结构:
personid INT,
name STRING,
mobilephone STRING,
homephone STRING
和目标表结构:
personid INT,
telephone ARRAY<STRING>
要从源插入目标,我做了
select
personid,
array(mobilephone, homephone)
from source_table
12, ["+1958523366","+1258523366"]
13, ["+1958523366",""]
结果中的第二行显示空字符串,因为homephone
在源表中为空。如何返回这样的东西:
12, ["+1958523366","+1258523366"]
13, ["+1958523366"]
即。仅当数组不为空时才返回数组
答案 0 :(得分:0)
select
personid,
split(concat_ws(',',mobilephone,homephone),',')
from source_table