set hive.map.aggr=true 时统计PV数据错误
从一个表里group by 之后 计算累加值、去重值:
为了效率设置并行:set hive.exec.parallel=true(可选:set hive.exec.parallel.thread.number=16)、set hive.groupby.skewindata=true、set hive.map.aggr=true
select plat, pagetype, count(*) pv, count(distinct userkey) uv from client_pv_form where dt = '2015-08-19' group by plat, pagetype union all select plat, 'all' pagetype, count(*) pv, count(distinct userkey) uv from client_pv_form where dt = '2015-08-19' group by plat union all select 'all' plat, pagetype, count(*) pv, count(distinct userkey) uv from client_pv_form where dt = '2015-08-19' group by pagetype union all select 'all' plat, 'all' pagetype, count(*) pv, count(distinct userkey) uv from client_pv_form where dt = '2015-08-19'
坏就坏在:set hive.map.aggr=true,map端聚合的设置;
出来的pv数跟真实值对不上;
改成下边代码运行正确;
select plat, pagetype, sum(1) pv, count(distinct userkey) uv from client_pv_form where dt = '2015-08-19' group by plat, pagetype union all select plat, 'all' pagetype, sum(1) pv, count(distinct userkey) uv from client_pv_form where dt = '2015-08-19' group by plat union all select 'all' plat, pagetype, sum(1) pv, count(distinct userkey) uv from client_pv_form where dt = '2015-08-19' group by pagetype union all select 'all' plat, 'all' pagetype, sum(1) pv, count(distinct userkey) uv from client_pv_form where dt = '2015-08-19'

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
浅谈zookeeper的在hbase集群中的作用
一,什么是zookeeper? ZooKeeper 顾名思义 动物园管理员,他是拿来管大象(Hadoop) 、 蜜蜂(Hive) 、 小猪(Pig) 的管理员, Apache Hbase和 Apache Solr 以及LinkedIn sensei 等项目中都采用到了 Zookeeper。ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,ZooKeeper是以Fast Paxos算法为基础,实现同步服务,配置维护和命名服务等分布式应用。 上面的解释感觉还不够,太官方了。Zookeeper 从程序员的角度来讲可以理解为Hadoop的整体监控系统。如果namenode,HMaster宕机后,这时候Zookeeper 的重新选出leader。这是它最大的作用所在。 二、zookeeper的作用 1.Zookeeper加强集群稳定性 Zookeeper通过一种和文件系统很像的层级命名空间来让分布式进程互相协同工作。这些命名空间由一系列数据寄存器组 成,我们也叫这些数据寄存器为znodes。这些znodes就有点像是文件系统中的文件和文件夹。和文件系统不一样的是,文件系统的文...
- 下一篇
Java在HBase数据库创建表
版权声明:本文为博主chszs的原创文章,未经博主允许不得转载。 https://blog.csdn.net/chszs/article/details/47836681 Java在HBase数据库创建表 作者:chszs,版权所有,未经同意,不得转载。博主主页:http://blog.csdn.net/chszs 要通过Java在HBase中创建一个数据表,首先需要导入hbase-client.jar驱动包。可以在项目pom.xml配置文件中添加依赖: <dependency> <groupId>org.apache.hbase</groupId> <artifactId>hbase-client<artifactId> <version>1.1.0.1</version> <dependency> 在添加依赖后,我们需要创建Configuration对象,并指定core-site.xml和hbase-site.xml作为资源文件。 Configuration config = HBase...
相关文章
文章评论
共有0条评论来说两句吧...