Lin Ma
Lin Ma

Reputation: 10139

hive group-by dealing with empty values

Suppose I am using Hive to group by a column, and the column could have value 1, 2, 3 or empty, wondering if I just need to simply write group by <column name> to handle empty values?

The purpose of my analysis is to count how many rows have value 1, 2 3 and empty individually.

BTW, the type of the column is string.

thanks in advance, Lin

Upvotes: 0

Views: 4191

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269883

If by "empty" you mean NULL, then, yes, you can use group by. This query:

select col, count(*)
from table t
group by col;

will return a separate row for NULL.

Upvotes: 2

Related Questions