计算 Hive 中列的 missing/default 值行的最佳方法是什么?
What is the best way to count the missing/default value rows of a column in Hive?
select
count(COLUMN_A is null or COLUMN_A like '0*') as num_miss_rows,
count(*) as num_total_rows
from tableX;
无效。因为 count(expr) 函数在任何 expr returns 非空值甚至 0.
上递增
我想为许多列计算 num_miss_rows/num_total_rows。
进行此计数的最佳方法是什么?
您想在总和中使用大小写(也应该是 like 0%
而不是 like 0*
):
select
sum(case when COLUMN_A is null or COLUMN_A like '0%' then 1 end) as num_miss_rows,
count(*) as num_total_rows
from tableX;
select
count(COLUMN_A is null or COLUMN_A like '0*') as num_miss_rows,
count(*) as num_total_rows
from tableX;
无效。因为 count(expr) 函数在任何 expr returns 非空值甚至 0.
上递增我想为许多列计算 num_miss_rows/num_total_rows。
进行此计数的最佳方法是什么?
您想在总和中使用大小写(也应该是 like 0%
而不是 like 0*
):
select
sum(case when COLUMN_A is null or COLUMN_A like '0%' then 1 end) as num_miss_rows,
count(*) as num_total_rows
from tableX;