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. 5 多线程 模拟qq聊天

    1.多线程思路 使用多线程完成一个全双工的QQ聊天程序 2.版本1:程序小框架 #1.收数据,然后打印 def recvData(): pass #2.检测键盘,发数据 def sendData(): ...

  2. java中array,arrayList,iterator;

    Array        String []a = new String[10] ;  a[0] = "test" ; String []a = new String[]{&quo ...

  3. python的正则表达一

    一.常用的正则表达式 1.了解正则表达式 正则表达式是对字符串操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种 ...

  4. 关于 poorpool

    poorpool 真名 chenyixiao.是一条傻逼题都不会做的没有脑子的咸鱼. 山西省临汾第一中学 高二 sx省队里最菜的那一个进队靠暴力. 普通的理科生,曾经爱好数学,然而到了高中发现自己所谓 ...

  5. dubbo心跳机制 (1)

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

  6. C++重载赋值操作符

    1.C++中重载赋值操作函数应该返回什么? 类重载赋值操作符一般都是作为成员函数而存在的,那函数应该返回什么类型呢?参考内置类型的赋值操作,例如 int x,y,z; x=y=z=15; 赋值行为相当 ...

  7. 「日常训练」「小专题·USACO」 Wormholes(1-4)

    题意 之后补充. 分析 这是一条很好的考察递归(或者说搜索)的题目.它的两个过程(建立初步解,验证)都用到了递归(或者说运用递归可以相当程度的减少代码量). 具体实现见代码.注意,为了使用std::p ...

  8. Java集合(2)——深入理解ArrayList、Vector和LinkedList

    回顾 Java集合主要分为两个体系结构,Collection和Map.这篇博客主要介绍Collection子接口List下的三个经常使用的实现类:ArrayList.Vector和LinkedList ...

  9. 如何使用 window.open() 处理ajax请求返回的url: 在本页面打开并防止浏览器拦截

    ajax请求中用window.open()打开请求返回url(例如实现下载功能时),可能会因为跨域问题导致浏览器拦截 解决办法是:在请求前,打开一个窗口,请求成功后将返回的url直接赋值给该窗口的hr ...

  10. C# 获取方法所在的 命名空间 类名 方法名

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...