从SQL中的数组中删除null

Mys*_*nge 5 sql arrays hive hiveql

想要从Hive / SQL中的数组中删除空值

例如:数组转换为字符串值后为['1',null],则仅应为'1'。

拆分数组我正在使用以下:

concat_ws( ",", array_val)

this gives : 1,null

required output : 1
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!

lef*_*oin 2

使用 regexp_replace 从连接字符串中删除 null:

hive> select regexp_replace('null,1,2,null,2,3,null','(,+null)|(^null,)','');
OK
1,2,2,3
Time taken: 6.006 seconds, Fetched: 1 row(s)
Run Code Online (Sandbox Code Playgroud)