select t.*
,concat(elt(e.pos+1,'Col_A','Col_B','Col_C','Col_D'),' failed null check') as New_Col
from mytable t lateral view posexplode (array(Col_A,Col_B,Col_C,Col_D)) e
where e.val is null
select Col_A, Col_B, Col_C, Col_D, 'Col_A failed NULL check' as new_col
from t
where Col_A is null
union all
select Col_A, Col_B, Col_C, Col_D, 'Col_B failed NULL check' as new_col
from t
where Col_B is null
union all
select Col_A, Col_B, Col_C, Col_D, 'Col_C failed NULL check' as new_col
from t
where Col_C is null
union all
select Col_A, Col_B, Col_C, Col_D, 'Col_D failed NULL check' as new_col
from t
where Col_D is null;
2条答案
按热度按时间laximzn51#
db2dz4w82#
一种方法使用
union all
:这是相当残忍的武力。如果有很多列,可以使用电子表格生成sql。这还需要对每个子查询进行单独的扫描。