当前位置: 首页 > 编程日记 > 正文

hive向表格中插入数据并分析语句

1,---导入mds_imei_month_info

set hive.exec.max.dynamic.partitions= 100000; //最大的动态分区表
set hive.support.concurrency=false; //是否支持并发
set hive.exec.max.dynamic.partitions.pernode= 100000; //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,'201705' as month,sum(pow(2,(dt-1))) as dt,sum(cnt) cnt //将自下面取出的dt进行指数的转换,pow(2,(dt-1))表示2的dt-1次方,cnt表示imei在这个月出现的次数
(select imei_p,cast(substring(dt,7,2) as int) as dt,count(*) cnt from mds_engine_basic where dt>=20170501 and dt<=20170531 and length(dt)=8 group by imei_p,dt //dt一共8位数,从第7位数开始的2位数取出,既01到31) a group by imei_p)a where length(imei_p)>=14 and regexp_extract(imei_p,'([a-z,,.,A-Z,0-9,_,\\-]*)',0)=imei_p //这是对imei进行正则匹配 )a;


2,---导入mds_ip_month_info

set hive.exec.max.dynamic.partitions= 100000;
set hive.support.concurrency=false;
set hive.exec.max.dynamic.partitions.pernode= 100000;
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,'201705' as month,sum(pow(2,(dt-1))) as dt,sum(cnt) cnt,country,city,province,latitude,longtitude,isp
from(
select user_ip,cast(substring(dt,7,2) as int) as dt,count(*) cnt,ipaddressquery(2,user_ip) country,
ipaddressquery(3,user_ip) province,ipaddressquery(1,user_ip) city, split(ipaddressquery(5,user_ip),',')[1]  longtitude ,
split(ipaddressquery(5,user_ip),',')[0]  latitude,
ipaddressquery(4,user_ip) isp  from mds_engine_basic where dt>=20170501 and dt<=20170531 and length(dt)=8 and user_ip not like '%,%'
and      split(user_ip,',')[0]  like '%.%.%' and regexp_extract( split(user_ip,',')[0],'\.([0-9]{0,7})\.([0-9]{0,7})\.([0-9]{0,7})\.([0-9]{0,7})',0)= split(user_ip,',')[0]  and split(user_ip,'\\.')[0]<300
group by user_ip,dt,ipaddressquery(2,user_ip) ,
ipaddressquery(3,user_ip) ,ipaddressquery(1,user_ip) , split(ipaddressquery(5,user_ip),',')[1]   ,
split(ipaddressquery(5,user_ip),',')[0]  ,
ipaddressquery(4,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= 100000;
set hive.support.concurrency=false;
set hive.exec.max.dynamic.partitions.pernode= 100000;
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,'201705' as month,sum(pow(2,(dt-1))) as dt,sum(cnt) cntfrom(select id,cast(substring(dt,7,2) as int) as dt,count(*) cnt from mds_engine_basic where dt>=20170501 and dt<=20170531 and length(dt)=8 group by id,dt) a group by id)a where length(id)=16 and regexp_extract(id,'([a-z,,.,A-Z,0-9,_,\\-]*)',0)=id 
)a;

4,---导入mds_bssid_month_info

set hive.exec.max.dynamic.partitions= 100000;
set hive.support.concurrency=false;
set hive.exec.max.dynamic.partitions.pernode= 100000;
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,'201709' as month,sum(pow(2,(dt-1))) as dt,sum(cnt) cntfrom(select bssid,cast(substring(dt,7,2) as int) as dt,count(*) cnt from mds_engine_wifi where dt>=20170901 and dt<=20170930 and length(dt)=8 group by bssid,dt) a group by bssid)a where length(bssid)>=14 
)a;

转载于:https://www.cnblogs.com/huxinga/p/7647219.html

相关文章:

资源与工具下载

Red Hat Linux镜像文件 链接&#xff1a;https://pan.baidu.com/s/1N3Khh6pyKpMkOnkEL-U9_A 提取码&#xff1a;0hnu jdk1.8(32位64位)安装版 链接&#xff1a;https://pan.baidu.com/s/15Jm6Ca6IBR3OEauge-4FYQ 提取码&#xff1a;uo2l Tomcat 8(32位64位)安装版 链接…

Global.asax中Application_Error无法执行

Global.asax中Application_Error无法执行问题解决后才发现这句是错误的&#xff0c;之前用VS2005开发后发布到服务器上也出现这种情况&#xff0c;后来莫名 的好了(是解决了没发现原因)。之前的文章链接后来用catch捕捉后真相大白&#xff0c;System.Security.SecurityExceptio…

虚拟化如何做实?详解戴尔2.0版解决方案

继5月份推出虚拟化解决方案后&#xff0c;2008年9月16日&#xff0c;戴尔又宣布推出包括新款服务器、存储产品&#xff0c;管理工具及基础设施咨询服务在内的全新虚拟化2.0解决方案&#xff0c;致力于为客户提供通向虚拟化的智慧之道。戴尔的虚拟化解决方案包括哪些具体的内容&…

Socket/ServerSocket 选项

Socket/ServerSocket 选项 原文:Socket/ServerSocket 选项在网络编程中&#xff0c;Socket/ServerSocket有一些选项用来自定义一些行为&#xff0c;现在分享一下。Socket选项 1.TCP_NODELAY 在Socket发送数据时&#xff0c;默认情况下&#xff0c;数据会先进入缓冲区&#xff0…

MySQL主从复制的常用拓扑结构

1、复制的常用拓扑结构 复制的体系结构有以下一些基本原则&#xff1a; (1) 每个slave只能有一个master&#xff1b; (2) 每个slave只能有一个唯一的服务器ID&#xff1b; (3) 每个master可以有很多slave&#xff1b; (4) 如果你设置log_slave_updates&#xff0c;…

统计java文件中的代码行数

统计Java代码行数工具类 —— CodeCounterUtil.java 统计指定目录下的java文件中代码行数 —— public static int getCodeNumFromFolder(String filePath)统计具体文件中的java代码行数 —— public static int getCodeNumFromFile(String filePath)import java.io.Buf…

jQuery插件thickbox在ie下垂直居中问题

jQuery 插件 thickbox 3.1 在ie下总不能垂直居中&#xff0c;按“http://jamazon.co.uk/web/2008/03/17/thickbox-31-ie7-positioning-bug/”上的方法改了也没用&#xff0c;咋办&#xff1f; 我是这样改的&#xff1a;管它ie6还是ie789&#xff0c;一视同仁&#xff01; 原284…

dos分区:C语言建立多个PRI DOS分区

dos分区:C语言建立多个PRI DOS分区 来源: 发布时间:星期四, 2008年9月25日 浏览:127次 评论:0一、引言 在DOS系统下&#xff0c;在计算机应用培训中因培训要求不同&#xff0c; 对软件的要求也不同&#xff0c;由于学员的误操作&#xff0c;存放在硬盘上的软件和重要数据容 易被…

简单几步让CentOS系统时间同步

在使用CentOS系统的时候&#xff0c;我们可能会遇到时间不准的问题&#xff0c;那我们如何解决这个我问题呢&#xff0c;下面就来教大家一个CentOS系统时间同步的方法&#xff0c;希望大家可以解决自己所存在的疑问。 CentOS系统时间同步的步骤如下&#xff1a; 新装的CentOS系…

挨踢人生路--记我的10年18家工作经历 - 后记

挨踢人生路--记我的10年18家工作经历 &#xff0d; 前言挨踢人生路--记我的10年18家工作经历 &#xff0d; 从大学说起――不得不说的一些事情挨踢人生路--记我的10年18家工作经历 &#xff0d; 第1家公司&#xff0c;在老家的工作挨踢人生路--记我的10年18家工作经历 &#xf…

FileUtil

文件工具类 —— FileUtil.java 获取Web工程的根目录 —— String getBasePath()方法获取文件名称 —— public static String getFileName(String filePath)方法获取文件名称前缀 —— public static String getPrefixOfFileName(String filePath)方法获取文件名后缀(…

C# Sato CL4NX打印机发送SBPL指令打印表面信息、RFID芯片数据写入

待更新..转载于:https://www.cnblogs.com/zh7791/p/7650073.html

同步SQL Server 2000 数据库

为什么要同步SQL Server 2000 数据库&#xff0c;它都用在什么场合 数据实时备份同步&#xff0c;数据库服务器出问题时我们也有其正常工作时的备份 数据实时备份同步&#xff0c;一台服务器负载不起时&#xff0c;可以用来做负载均衡 数据实时备份同步&#xff0c;数据库服务器…

【Leecode】两数相加

学习了链表结构&#xff0c;链表中元素的访问&#xff0c;对象指针的初始化与赋值&#xff0c;链表的创建&#xff08;多个节点链接起来&#xff09;&#xff0c;进位计算的表达。 100ms /*** Definition for singly-linked list.* struct ListNode {* int val;* ListN…

推荐一个HTML的语法高亮解析器

http://code.google.com/p/syntaxhighlighter/wiki/Languages支持高亮的语法如下Language Aliases C cpp, c, c C# c#, c-sharp, csharp CSS css Delphi delphi, pascal Java java Java Script js, jscript, javascript PHP php Python py, python Ruby rb, ruby, rails, ror S…

angularJS中directive与controller之间的通信

当我们在angularJS中自定义了directive之后需要和controller进行通讯的时候&#xff0c;是怎么样进行通讯呢&#xff1f; 这里介绍3种angular自定义directive与controller通信的指令。 1.指令作用域中的"" 作用&#xff1a;把当前属性作为字符串传递实现指令与html页…

Eclipse启动失败:No java virtual machine was found after searching the follwing locations

Eclipse启动失败&#xff0c;错误信息如下如所示&#xff1a; 通过阅读错误信息&#xff0c;可以看到错误原因和 javaw.exe路径 有关&#xff1b; 打开eclipse.ini文件&#xff0c;也就是启动Eclipse的初始化文件&#xff1a; 在本地计算机中找到jdk安装路径下javaw.exe文件&a…

Cisco路由器安全配置必用10条命令

当谈到配置一台新的cisco路由器&#xff0c;多数配置依赖于路由器的类型以及它将服务的用途。然而&#xff0c;每位管理员都有其自己的“正确”配置每台路由器的命令列表。笔者将和你分享他自己配置路由器的十条命令列表。<?xml:namespace prefix o ns "urn:schemas…

Tensorflow学习教程------模型参数和网络结构保存且载入,输入一张手写数字图片判断是几...

首先是模型参数和网络结构的保存 #coding:utf-8 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_datamnist input_data.read_data_sets(MNIST_data,one_hotTrue) #每个批次的大小 batch_size 100 n_batch mnist.train._num_examples // ba…

IntelliJ IDEA乱码问题解决方法

目录 1、设置文件编码 2、设置控制台编码 3、设置Tomcat Server编码 4、修改配置文件编码内容 1、设置文件编码 第1步&#xff1a;打开IDEA&#xff0c;依次点击File、Settings... 打开Setting窗口&#xff1b; 第2步&#xff1a;在Settings窗口中&#xff0c;依次点击Ed…

Windows 7的CMD中 Telnet 无法执行的解决办法

在Windows 7的CMD中&#xff0c;执行telnet 192.168.1.10 80 会提示没有这个命令的提示&#xff0c;这是因为Win7默认是没有安装Telnet的&#xff08;在以往的WINDOWS系统中都是默认安装的&#xff09;。解决办法&#xff1a;在Win7中&#xff0c;进入控制面板&#xff0c;然后…

Qt——模态、非模态

模态&#xff1a; 只能操作对话框非模态&#xff1a;要使用 QDialog *_d new QDialog();_d->setattribute(Qt::WA_DeleteOnClose);_d->show();转载于:https://www.cnblogs.com/yangxinrui/p/10515249.html

c# 取两个时间的间隔

c#可以取两个时间的年月日时分秒之间的间隔&#xff0c;不受跨年月的影响。声明一个 TimeSpan System.TimeSpan ts dtNightEnd.Subtract(dtAmStart); dtNightEnd是原始时间 减去 dtAmStart 这个时间 获得一个TimeSpan TimeSpan 自带了间隔属性 ts.Days.ToString(); ts.Hours.…

MySQL数据表命令

显示表的相关信息&#xff1a; show table status like "表名"&#xff1b; show table status like "表名" \G 格式化&#xff0c;以记录条目形式显示&#xff0c;更清晰 注意&#xff1a;\G后面不能加分号&#xff0c;不然会出现查询错误。因为\G在…

undefined reference to 'pthread_create'问题解决(转)

undefined reference to pthread_createundefined reference to pthread_join问题原因&#xff1a;pthread 库不是 Linux 系统默认的库&#xff0c;连接时需要使用静态库 libpthread.a&#xff0c;所以在使用pthread_create()创建线程&#xff0c;以及调用 pthread_atfork()函数…

C语言程序设计第一次作业

&#xff08;一&#xff09;实验总结 1.圆的面积和周长问题 &#xff08;1&#xff09;题目&#xff1a; 输入圆的半径&#xff0c;计算圆的周长和面积。 &#xff08;2&#xff09;流程图 &#xff08;3&#xff09;测试数据及运行结果 &#xff08;4&#xff09;实验分析 问题…

U盘中毒,无法删除System Volume Information文件夹

情景&#xff1a;U盘中毒&#xff0c;U盘内的文件夹名称变成.exe后缀&#xff0c;且多出一个名为System Volume Information的文件夹&#xff0c;对U盘进行格式化后&#xff0c;所有文件消失&#xff0c;当拔出U盘&#xff0c;再次插入电脑时&#xff0c;发现System Volume Inf…

用Javascript修正12个常见的浏览器问题

我们提倡尽可能使用CSS&#xff0c;而且我们常常能做到这一点。现代浏览器有很好的CSS支持-这无疑足够好让你使用CSS来控制布局和版面设计。但是有时候&#xff0c;某些网页元素在不同的浏览器会出现不同。 如果你不知道原因&#xff0c;不要过于担心&#xff0c;请研究CSS规则…

读书笔记之知识杂点

1.xx1,x1,x,哪个效率最高?为什么? xx1最低&#xff0c;因为它的执行过程如下&#xff1a; &#xff08;1&#xff09;读取右x的地址 &#xff08;2&#xff09;x1 &#xff08;3&#xff09;读取左x的地址 &#xff08;4&#xff09;将右值传给左边的x(编译器并不认为左右的x…

Codeforces.487C.Prefix Product Sequence(构造)

题目链接 \(Description\) 对于一个序列\(a_i\)&#xff0c;定义其前缀积序列为\(a_1\ \mathbb{mod}\ n,\ (a_1a_2)\ \mathbb{mod}\ n,...,(a_1a_2...a_n)\ \mathbb{mod}\ n\)。 给定\(n\)&#xff0c;求一个\(n\)的排列&#xff0c;使得该排列的前缀积序列是\([0,1,2,...,n-1]…