hive to a null value is listed avg, will not filter null value sum, count and other operations

In the hive, we often encounter on a column count, sum, avg and other operations to calculate the number of records, sum, average, etc., but this column has a null value is often the case, that these actions will not You can filter out null?

Here's a brief test at:

with tmp as
(
select null as col1
 union all
select 666 as col1
 union all
select 999 as col1
)
select avg(col1) avg_numm, sum(col1) sum_num, count(1) cnt, count(col1) cnt_col1
  from tmp

832.5	1665	3	2

It is easy to conclude from the results: avg, sum, count will filter out null values

Guess you like

Origin blog.csdn.net/lz6363/article/details/91041435