hive不分区增量更新
insert overwrite table ods.zeg_so
select
*,
case when zsm.id is not null then cast(current_timestamp as string) else zs.etl_update end etl_update
from ods.zeg_so_mid zsm
full join ods.zeg_so zs on zsm.id=zs.id
----------------------------------------------------------
insert overwrite table data_center.test_no_partition
select tmp.id,tmp.name,tmp.age
from tmp.temp_test_no_partition tmp
full join data_center.test_no_partition org
on tmp.id=org.id
#hive全连接
insert overwrite table data_center.test_no_partition
select tmp.id,tmp.name,tmp.age from tmp.temp_test_no_partition tmp
union all
select org.id,org.name,org.age from data_center.test_no_partition org
left outer join tmp.temp_test_no_partition b
on org.id=b.id
--------------------------------------------------------------
insert overwrite table data_center.test_no_partition
select tmp.id,tmp.name,tmp.age from tmp.temp_test_no_partition tmp
union all
select b.id,b.name,b.age from data_center.test_no_partition org
left outer join tmp.temp_test_no_partition b
on org.id=b.id
----------------------------------------------------------------
insert overwrite table data_center.test_no_partition
select tmp.id,tmp.name,tmp.age from tmp.temp_test_no_partition tmp
full join data_center.test_no_partition org on tmp.id=org.id
--------------------------------------------------------------------
insert overwrite table data_center.test_no_partition
select org.id,org.name,org.age from tmp.temp_test_no_partition tmp
full join data_center.test_no_partition org on tmp.id=org.id
--------------------------------------------------------------------------------
不分区增量更新 OK
insert overwrite table data_center.test_no_partition
select tmp.id,tmp.name,tmp.age from tmp.temp_test_no_partition tmp
union all
select org.id,org.name,org.age from data_center.test_no_partition org
left outer join tmp.temp_test_no_partition b
on org.id=b.id
where b.id is null;
分区:增量更新
INSERT OVERWRITE TABLE %s.%s PARTITION(%s) select %s from %s''' % (job_info_map["w_database"], job_info_map["w_table"], job_info_map["w_partition_name"],
colums_str, "temp." + job_info_map["temp_table"])
hive_sql = "set hive.exec.dynamic.partition.mode=nonstrict;"
hive_sql += "set hive.exec.max.dynamic.partitions.pernode=1000;"
hive_sql += "set mapreduce.reduce.shuffle.input.buffer.percent=0.5;"
hive_sql += "INSERT OVERWRITE TABLE " + hive_table + " PARTITION(" + job_info_map["w_partition_name"] + ")" + "\nSELECT " + colums_str + " FROM " + temp_table + " UNION ALL SELECT a.* FROM " + hive_table + " a LEFT OUTER JOIN " + temp_table + " b on "
#增量取数据条件
update_time>=subdate(current_date,1)
COALESCE(update_time,create_Time)>=subdate(current_date,1)
-------------------------------------------------------------------
#分区增量更新语句:
insert overwrite table data_center.test_partition partition(date_id='2017-06-13')
select tmp.id,tmp.name,tmp.age from tmp.temp_test_partition tmp
union all select org.id,org.name,org.age from data_center.test_partition org
left outer join tmp.temp_test_partition b
on org.id=b.id
where b.id is null;
报错:SemanticException [Error 10044]: Line 1:23 Cannot insert into target table because column number/types are different ''2017-06-13'': Table insclause-0 has 3 columns,
but query has 4 columns
CREATE TABLE `tmp.temp_test_partition`(
`id` int,
`name`
string,
`age` int)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.l
azy.LazySimpleSerDe'
WITH SERDEPROPERTIES ( 'field.delim'=',', 'serialization.format'=',')
STORED AS INPUTFORMAT
'org.apache.hadoop.mapred.TextInputF
ormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFor
mat'
LOCATION
'hdfs://master:9000/user/hive/warehouse/tmp.db/temp_test_partiti
on' TBLPROPERTIES ( 'transient_lastDdlTime'='1497492633')
alter table tmp.temp_test_partition set serdeproperties ('field.delim'=',','serialization.format'=',')
#分区增量更新语句:OK
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=1000;
set mapreduce.reduce.shuffle.input.buffer.percent=0.5;
insert overwrite table data_center.test_partition partition(date_id)
select tmp.id,tmp.name,tmp.age,'2017-06-15' as date_id from tmp.temp_test_partition tmp
union all select a.* from data_center.test_partition a
left outer join tmp.temp_test_partition b on a.id=b.id where b.id is null and a.date_id in ('2017-06-14','2017-06-15','2017-06-16');
#删除部分数据
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=1000;
set mapreduce.reduce.shuffle.input.buffer.percent=0.5;
insert overwrite table data_center.test_partition partition (date_id) select id,name,age,date_id from data_center.test_partition limit 2;
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.max.dynamic.partitions.pernode=1000;
set mapreduce.reduce.shuffle.input.buffer.percent=0.5;
insert overwrite table data_center.test_partition partition (date_id) select id,name,age,date_id from data_center.test_partition where name in ('lisi','ccc')
hive不分区增量更新的更多相关文章
- 使用hive增量更新
目录 1.增量更新 2.对第一种情况 2.1.准备工作 2.2.更新数据 3.对第二种情况 3.1.准备工作 3.2.方法1 3.3.方法2 参考文末文章,加上自己的理解. 1.增量更新 有一个 ba ...
- 数仓增量更新hive实现
注:参考文末文章,加上自己的理解. 1.增量更新 有一个 base_table 表存放的是 12 月 15 日之前的所有数据,当 12 月 16 日的数据产生后,生成了一个 incremental_t ...
- 大数据系列之数据仓库Hive中分区Partition如何使用
Hive系列博文,持续更新~~~ 大数据系列之数据仓库Hive原理 大数据系列之数据仓库Hive安装 大数据系列之数据仓库Hive中分区Partition如何使用 大数据系列之数据仓库Hive命令使用 ...
- hive表分区相关操作
Hive 表分区 Hive表的分区就是一个目录,分区字段不和表的字段重复 创建分区表: create table tb_partition(id string, name string) PARTIT ...
- 谈谈混合 App Web 资源的打包与增量更新
综述 移动 App 的运行环境具有带宽不稳定,流量收费,启动速度比较重要等特点,所以混合 App 如何加载 Web 资源并不是一个新问题.本文目的是总结出一种资源打包下载的思路和方案,并且提供一种打包 ...
- SSIS Design2:增量更新
一般来说,ETL实现增量更新的方式有两种,第一种:记录字段的最大值,如果数据源中存在持续增加的数据列,记录上次处理的数据集中,该列的最大值:第二种是,保存HashValue,快速检查所有数据,发现异动 ...
- android studio增量更新
一.概述 1.1 概念 增量更新即是通过比较 本机安装版本 和 想要安装版本 间的差异,产生一个差异安装包,不需要从官网下载并安装全量安装包,更不需要将本机已安装的版本下载,而仅仅只是安装此差异安装包 ...
- Android 增量更新(BSDiff / bspatch)
Android 增量更新 BSDiff / bspatchhttp://www.daemonology.net/bsdiff/android的代码目录下 \external\bsdiff bsdiff ...
- 【转载】Unity 合理安排增量更新(热更新)
原帖地址:由于我看到的那个网站发的这篇帖子很大可能是盗贴的,我就暂时不贴地址了.避免伤害原作者 原版写的有点乱,我个人修改整理了下. --------------------------------- ...
随机推荐
- 对js原型对象、实例化对象及prototype属性的一些见解
什么是原型对象? 请看下面的代码,我们以各种姿势,创建了几个方法! function fn1() { } var fn2 = function () { } var fn3 = new Functio ...
- 增加游戏受众:在英特尔核显上运行MR游戏
为了获得良好的用户体验,通常VR游戏需要稳定在每秒90帧,这意味着整个场景只有11.1毫秒的时间来进行左右眼渲染,这就是为何VR游戏需要配备高端的独立显卡.现在来看看我们如何使用最新版英特尔图形性能分 ...
- script学习,如何用linux监控你的同事?
环境:CentOS7 一.为什么要学习script命令 当你在终端或控制台上工作时,你想记录下自己做了些什么吗?当你跟一些Linux管理员同时在系统上干活,你想知道别人干了什么吗?当你让别人远程到你的 ...
- 类属性与对象实现,init方法的作用,绑定方法,绑定方法与普通函数的区别,继承,抽象与继承,派生与覆盖
今日内容: 1.类属性与对象属性 2.init方法的作用 3.绑定方法 4.绑定方法与普通函数的区别(非绑定方法) 5.继承 6.抽象与继承 7.派生与覆盖 1.类属性与对象属性 类中应该进存储所有对 ...
- Spring Boot(2)中的yaml配置简介
搞Spring Boot的小伙伴都知道,Spring Boot中的配置文件有两种格式,properties或者yaml,一般情况下,两者可以随意使用,选择自己顺手的就行了,那么这两者完全一样吗?肯定不 ...
- mysql常用排查命令
1.查看服务器使用状态 mysqladmin -uroot -p -S /tmp/mysql.sock -r -i 1 ext |\ awk -F"|" \ "BEGIN ...
- idea自动化部署插件 Alibaba Cloud Toolkit 使用记录
官方安装文档和使用说明 https://help.aliyun.com/product/29966.html?spm=a2c4g.11186623.6.540.6efa6029JhlPfx 是什么? ...
- python函数 -- 作用域,异常处理
1.def语句和参数 python定义函数的关键词为def,格式如下: def 函数名([变元],[变元],....) #保存在变元中的值,在函数返回后该变元就会被销毁了. 2.返回 ...
- centos 7 源码安装 mysql 5.6
下载 mysql 安装包 $ wget https://cdn.mysql.com//Downloads/MySQL-5.6/mysql-5.6.44.tar.gz # or $ curl -O ht ...
- IDEA2018.2.6激活(可用)
破解插件下载: 链接:https://pan.baidu.com/s/1j2_kEm_Akcph6Qb8hr6soQ 提取码:hv64 将下载包放入bin文件夹下,修改bin中的两个文件 idea.e ...