Mapreduce 为什么蜂巢没有';使用group by时不显示空分区计数?
这只是一个好奇:为什么当我使用GROUPBY时,hive不显示空分区计数Mapreduce 为什么蜂巢没有';使用group by时不显示空分区计数?,mapreduce,group-by,hive,hdfs,Mapreduce,Group By,Hive,Hdfs,这只是一个好奇:为什么当我使用GROUPBY时,hive不显示空分区计数 select count(*), partition_date from table group by partition_date; 结果是: count----------------partition_date 746 ----------------20160901 1155----------------20160906 589 ----------------20160907 639 ----------
select count(*), partition_date
from table
group by partition_date;
结果是:
count----------------partition_date
746 ----------------20160901
1155----------------20160906
589 ----------------20160907
639 ----------------20160908
763 ----------------20160909
1502----------------20160912
1188----------------20160913
601 ----------------20160914
675 ----------------20160915
766 ----------------20160916
现在我无法看到3个分区:20160905、20160904、20160903
如果我对这些特定分区进行计数,它会给出count=0
select count(*) from table where partition_date=20160905;
select count(*) from table where partition_date=20160904;
select count(*) from table where partition_date=20160903;
但这样做时,我没有使用group by,这就是为什么它会给我一个结果
如果我使用GROUPBY再次执行此操作,仍然会得到一个无效结果
select count(*), partition_date from table where partition_date=20160905 group by partition_date;
我尝试了其他方法,但仍然无法使用GROUPBY获得空分区的计数
select count(*), partition_date from table group by partition_date having count(*)>=0;
select count(*), partition_date from table group by partition_date having count(*)=0;
select count(*), partition_date from table where partition_date in (20160905, 20160904, 20160903) group by partition_date;
这是我找到的唯一解决办法,还有别的办法吗
select AA.partition_date,nvl(BB.CN,0) as CC
from (select distinct partition_date as partition_date from table) AA
left join
(select partition_date, count(*) as CN from table group by partition_date) BB
on AA.partition_date = BB.partition_date;
所以我最后的问题是:
- 这与MapReduce作业有关吗李>
- 这些MapReduce作业如何给出这些查询的结果
- 你知道一种计算空分区的复杂方法吗