我有一个名为part_nos_list的列作为数组< \ string>在蜂巢表中。显然该列已空白,我想用’ - ’更新它。代码排序可以做到但是组中有42行…
要测试爆炸数组元素是否为空,请使用以下命令:
select * from( select explode( array("OTC","POS","CCC","")) as explo ) s where explo=''
结果是一个空字符串: http://demo.gethue.com/hue/editor?editor=289227&type=hive
如果要识别包含空元素的数组,请使用 array_contains :
array_contains
select * from( select array("OTC","POS","CCC","") as a ) s where array_contains(a,'')
结果:
["OTC","POS","CCC",""]
看测试: http://demo.gethue.com/hue/editor?editor=289234
如果要查找仅包含一个元素的数组 - 使用空字符串 size(array)=1 and array_contains(array,'') , 看这里: http://demo.gethue.com/hue/editor?editor=289236
size(array)=1 and array_contains(array,'')
的 但也有空数组这样的东西 强> : http://demo.gethue.com/hue/editor?editor=289239&type=hive 它显示与包含空元素的数组相同,但它不相同: http://demo.gethue.com/hue/editor?editor=289240&type=hive
并找到空数组,使用 size()=0 例: http://demo.gethue.com/hue/editor?editor=289241 :
size()=0
select * from( select array() as a ) s where size(a)=0
返回 []
[]
对您的数据运行所有这些查询,您将变得开明。我认为它是空数组,在你的情况下不是空元素
空数组不是NULL,因为它仍然是零大小的数组对象: http://demo.gethue.com/hue/editor?editor=289242
select * from( select array() as a ) s where a is null
不返回任何行
更好的查询数组,不会爆炸和使用 array_contains 和 size 找到空数组和空元素。使用LATERAL VIEW 的 外 强> 即使LATERAL VIEW通常不会生成一行,也会生成行。没有OUTER字的LATERAL VIEW可以作为INNER JOIN使用,请参阅有关的文档 横向视图外
size