1,---导入mds_imei_month_info

set hive.exec.max.dynamic.partitions= ; //最大的动态分区表
set hive.support.concurrency=false; //是否支持并发
set hive.exec.max.dynamic.partitions.pernode= ; //each mapper or reducer可以创建的最大动态分区数
set hive.exec.dynamic.partition.mode=nonstrict; //strict是避免全分区字段是动态的,必须有至少一个分区字段是指定有值的
insert into table mds_imei_month_info partition(month)
select imei_p,dt,cnt ,month from
(
select imei_p ,month,dt,cnt from
(select imei_p,'' as month,sum(pow(,(dt-))) as dt,sum(cnt) cnt //将自下面取出的dt进行指数的转换,pow(2,(dt-1))表示2的dt-1次方,cnt表示imei在这个月出现的次数
(
select imei_p,cast(substring(dt,,) as int) as dt,count(*) cnt from mds_engine_basic where dt>= and dt<= and length(dt)= group by imei_p,dt //dt一共8位数,从第7位数开始的2位数取出,既01到31
) a group by imei_p)a where length(imei_p)>= and regexp_extract(imei_p,'([a-z,,.,A-Z,0-9,_,\\-]*)',)=imei_p //这是对imei进行正则匹配
)a;

2,---导入mds_ip_month_info

set hive.exec.max.dynamic.partitions= ;
set hive.support.concurrency=false;
set hive.exec.max.dynamic.partitions.pernode= ;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table mds_ip_month_info partition(month)
select user_ip,country,province,city,longtitude,latitude,isp,dt,cnt ,month from
(
select user_ip ,month,dt,cnt,country,city,province,latitude,longtitude,isp from
(select user_ip,'' as month,sum(pow(,(dt-))) as dt,sum(cnt) cnt,country,city,province,latitude,longtitude,isp
from(
select user_ip,cast(substring(dt,,) as int) as dt,count(*) cnt,ipaddressquery(,user_ip) country,
ipaddressquery(,user_ip) province,ipaddressquery(,user_ip) city, split(ipaddressquery(,user_ip),',')[] longtitude ,
split(ipaddressquery(,user_ip),',')[] latitude,
ipaddressquery(,user_ip) isp from mds_engine_basic where dt>= and dt<= and length(dt)= and user_ip not like '%,%'
and split(user_ip,',')[] like '%.%.%' and regexp_extract( split(user_ip,',')[],'\.([0-9]{0,7})\.([0-9]{0,7})\.([0-9]{0,7})\.([0-9]{0,7})',)= split(user_ip,',')[] and split(user_ip,'\\.')[]<
group by user_ip,dt,ipaddressquery(,user_ip) ,
ipaddressquery(,user_ip) ,ipaddressquery(,user_ip) , split(ipaddressquery(,user_ip),',')[] ,
split(ipaddressquery(,user_ip),',')[] ,
ipaddressquery(,user_ip)) a group by user_ip,country,city,province,latitude,longtitude,isp)a
)a ;

3,---导入mds_id_month_info

set hive.exec.max.dynamic.partitions= ;
set hive.support.concurrency=false;
set hive.exec.max.dynamic.partitions.pernode= ;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table mds_id_month_info partition(month)
select id,dt,cnt ,month from
(
select id ,month,dt,cnt from
(select id,'' as month,sum(pow(,(dt-))) as dt,sum(cnt) cnt
from
(
select id,cast(substring(dt,,) as int) as dt,count(*) cnt from mds_engine_basic where dt>= and dt<= and length(dt)= group by id,dt
) a group by id)a where length(id)= and regexp_extract(id,'([a-z,,.,A-Z,0-9,_,\\-]*)',)=id
)a;

4,---导入mds_bssid_month_info

set hive.exec.max.dynamic.partitions= ;
set hive.support.concurrency=false;
set hive.exec.max.dynamic.partitions.pernode= ;
set hive.exec.dynamic.partition.mode=nonstrict;
insert into table mds_bssid_month_info partition(month)
select bssid,dt,cnt ,month from
(
select bssid ,month,dt,cnt from
(select bssid,'' as month,sum(pow(,(dt-))) as dt,sum(cnt) cnt
from
(
select bssid,cast(substring(dt,,) as int) as dt,count(*) cnt from mds_engine_wifi where dt>= and dt<= and length(dt)= group by bssid,dt
) a group by bssid)a where length(bssid)>=
)a;

hive向表格中插入数据并分析语句的更多相关文章

  1. 在页面上绘制一张表格,使用 DOM 节点的动态添加和删除向表格中插入数据,点击表格每行后的“删除”超链接

    查看本章节 查看作业目录 需求说明: 在页面上绘制一张表格,使用 DOM 节点的动态添加和删除向表格中插入数据,点击表格每行后的"删除"超链接,使用 DOM 节点的删除操作将对应的 ...

  2. Hive通过查询语句向表中插入数据过程中发现的坑

    前言 近期在学习使用Hive(版本号0.13.1)的过程中,发现了一些坑,它们也许是Hive提倡的比关系数据库更加自由的体现(同一时候引来一些问题).也许是一些bug.总而言之,这些都须要使用Hive ...

  3. Hive通过查询语句向表中插入数据注意事项

    最近在学习使用Hive(版本0.13.1)的过程中,发现了一些坑,它们或许是Hive提倡的比关系数据库更加自由的体现(同时引来一些问题),或许是一些bug.总而言之,这些都需要使用Hive的开发人员额 ...

  4. 如何使用免费控件将Word表格中的数据导入到Excel中

    我通常使用MS Excel来存储和处理大量数据,但有时候经常会碰到一个问题—我需要的数据存储在word表格中,而不是在Excel中,这样处理起来非常麻烦,尤其是在数据比较庞大的时候, 这时我迫切地需要 ...

  5. 如何使用poi在word表格中插入行的4种方法

    本文记录了,在word表格中插入新行的几种方法.直接上代码说明 table.addNewRowBetween 没实现,官网文档也说明,只有函数名,但没具体实现,但很多文章还介绍如何使用这个函数,真是害 ...

  6. SQL语句的使用,SELECT - 从数据库表中获取数据 UPDATE - 更新数据库表中的数据 DELETE - 从数据库表中删除数据 INSERT INTO - 向数据库表中插入数据

    SQL DML 和 DDL 可以把 SQL 分为两个部分:数据操作语言 (DML) 和 数据定义语言 (DDL). SQL (结构化查询语言)是用于执行查询的语法. 但是 SQL 语言也包含用于更新. ...

  7. 使用C#向ACCESS中插入数据

    使用C#向ACCESS中插入数据   1.创建并打开一个OleDbConnection对象 string strConn = " Provider = Microsoft.Jet.OLEDB ...

  8. jQuery Ajax遍历表格,填充数据,将表格中的数据一条一条拼成Jason数组

    $.ajax({ url: baseURL + "InvoiceSale/OnQuotaInvoiceSale", //点击核销单号时,点击核销时,交互的页面           ...

  9. 触发器修改后保存之前的数据 表中插入数据时ID自动增长

    create or replace trigger t before update on test5 for each rowbegin insert into test55 values (:old ...

随机推荐

  1. P1331 海战

    P1331 海战 题目描述 在峰会期间,武装部队得处于高度戒备.警察将监视每一条大街,军队将保卫建筑物,领空将布满了F-2003飞机.此外,巡洋船只和舰队将被派去保护海岸线.不幸的是因为种种原因,国防 ...

  2. MapRudecer

    MapReducer基本概念 Mapreduce是一个分布式运算程序的编程框架,是用户开发“基于hadoop的数据分析应用”的核心框架: Mapreduce核心功能是将用户编写的业务逻辑代码和自带默认 ...

  3. 四大IO抽象类

     四大IO抽象类   InputStream/OutputStream和Reader/writer类是所有IO流类的抽象父类,我们有必要简单了解一下这个四个抽象类的作用.然后,通过它们具体的子类熟悉相 ...

  4. dubbo心跳机制 (1)

    此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. dubbo的心跳机制: 目的:检测provider与consumer之间的connection连接是不是还连 ...

  5. Borland和Micorsoft的对话(转载自月光软件网)

      Borland与Microsoft关于Delphi的对话 Bear 1.Delphi较贵  一套Delphi的价格大约相当于两套Visual Studio  ------------------- ...

  6. 【python模块】——logging

    python学习——logging模块

  7. create subnet

    子网相关功能点: 模块 功能 描述 备注 子网 创建子网 创建一个子网   设置子网网段范围   设置子网网关IP/不开启网关   给子网开启/关闭dhcp   设置子网dns   修改子网 修改子网 ...

  8. TensorFlow 常见错误与解决方法——长期不定时更新

    1. TypeError: Cannot interpret feed_dict key as Tensor: Can not convert a builtin_function_or_method ...

  9. hadoop节点之间通信问题

    前天遇到一个hadoop问题,由于之前都是伪分布的情况,没有真正的涉及到集群的环境,最近按照一些资料自己搭建了一个集群环境,三台虚拟机,一个master,两个slave,利用jps查看节点信息,启动了 ...

  10. IP数据报格式 及分组转发算法

    ip数据报分首部和数据两部分组成: 首部分为固定部分和可变部分 版本——占 4 位,指 IP 协议的版本 目前的 IP 协议版本号为 4 (即 IPv4) 首部长度——占 4 位,可表示的最大数值 是 ...