Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the list of all columns having NULL values only in hive?

I am working on a huge data set having more than 10k rows and more than 600 columns in Hive. There are multiple rows columns which having NULL value for all the rows. How can I get the list of all the columns having only NULL values?

like image 443
Manjeet Suman Avatar asked Dec 14 '25 14:12

Manjeet Suman


1 Answers

Use count(col) to count all NOT NULL rows for some column.

Columns with all NULLs will have 0 counts:

select
count(col1) as col1_cnt,
count(col2) as col2_cnt,
...
count(colN) as colN_cnt

from table
like image 144
leftjoin Avatar answered Dec 16 '25 04:12

leftjoin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!