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. JVM运行内存分配和回收

    本文来自网易云社区 作者:吕宗胜 Java语言与C语言相比,最大的特点是编程人员无需过多的关心Java的内存分配和回收,因为所有这一切,Java的虚拟机都帮我们实现了.JVM的内存管理,大大降低了开发 ...

  2. Java检测端口的占用情况

    突然间想到这个问题,在网上搜了一下 http://blog.csdn.net/danieluk/article/details/18518175 网上有很多文章都是用上面那个方法来解决这个问题的,总感 ...

  3. 孤荷凌寒自学python第七十六天开始写Python的第一个爬虫6

    孤荷凌寒自学python第七十六天开始写Python的第一个爬虫6 (完整学习过程屏幕记录视频地址在文末) 今天在上一天的基础上继续完成对我的第一个代码程序的书写. 不过由于对python-docx模 ...

  4. CF 55D

    Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer numb ...

  5. AGV系统上位机--工程案例【1】

    1.满足80%系统需求,根据需求生成任务表单 2.指定小车下方任务 3.项目实战应用 4.后台开发,对接其他平台,简易实现自动生成任务列表,自动排单 5.AGV系统上位机初学者很容易理解上手 6.欢迎 ...

  6. PAT——乙级1022:D进制的A+B &乙级1037:在霍格沃茨找零钱

    1022 D进制的A+B (20 point(s)) 输入两个非负 10 进制整数 A 和 B (≤2​30​​−1),输出 A+B 的 D (1<D≤10)进制数. 输入格式: 输入在一行中依 ...

  7. 文件特殊权限:SUID,SGID,SBIT

    我们之前认识的文件的权限仅局限于r,w,x,但如果我们执行命令“ll /tmp; ll /usr/bin/passwd”,会出现除了r,w,x之外的其他字母: 即出现了特殊权限(s跟t). [SetU ...

  8. 功能规格说明书Version2

    此功能规格说明书是Week8 功能规格说明书的第二个版本, 版本1地址:http://www.cnblogs.com/Z-XML/p/3407687.html 此功能规格说明书是面向用户的,所以作者将 ...

  9. Python调用MySQL的一些用法小结

    目标:1个excel表内容导入到数据库中,例如:原始excel文件为 aaa.xls 首先:将aaa.xls 转换成aaa.txt ,注意当文件中含有中文字符时,可以通过notepad++打开,在“格 ...

  10. Servlet入门(2)

    1.url_pattern匹配模式 2.servlet生命周期 3.servlet线程问题 一.url_pattern 1.定义: 当浏览器发起一个url请求后,该请求发送到servlet容器的时候, ...