user2942227
user2942227

Reputation: 1023

create hive table and find total NULL fields in each column

I need to write a query that returns number of null fields in every column in a hive table

eg:

col1|col2|col3
----------------
NULL|a   |b
NULL|a   |b
e   |NULL|f

the query should return 2 1 0 for the above table. Someone help please??

Upvotes: 1

Views: 960

Answers (1)

Joe K
Joe K

Reputation: 18424

select
sum(if(col1 is null, 1, 0)),
sum(if(col2 is null, 1, 0)),
sum(if(col3 is null, 1, 0))
from mytable

Upvotes: 2

Related Questions