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不分区增量更新的更多相关文章

  1. 使用hive增量更新

    目录 1.增量更新 2.对第一种情况 2.1.准备工作 2.2.更新数据 3.对第二种情况 3.1.准备工作 3.2.方法1 3.3.方法2 参考文末文章,加上自己的理解. 1.增量更新 有一个 ba ...

  2. 数仓增量更新hive实现

    注:参考文末文章,加上自己的理解. 1.增量更新 有一个 base_table 表存放的是 12 月 15 日之前的所有数据,当 12 月 16 日的数据产生后,生成了一个 incremental_t ...

  3. 大数据系列之数据仓库Hive中分区Partition如何使用

    Hive系列博文,持续更新~~~ 大数据系列之数据仓库Hive原理 大数据系列之数据仓库Hive安装 大数据系列之数据仓库Hive中分区Partition如何使用 大数据系列之数据仓库Hive命令使用 ...

  4. hive表分区相关操作

    Hive 表分区 Hive表的分区就是一个目录,分区字段不和表的字段重复 创建分区表: create table tb_partition(id string, name string) PARTIT ...

  5. 谈谈混合 App Web 资源的打包与增量更新

    综述 移动 App 的运行环境具有带宽不稳定,流量收费,启动速度比较重要等特点,所以混合 App 如何加载 Web 资源并不是一个新问题.本文目的是总结出一种资源打包下载的思路和方案,并且提供一种打包 ...

  6. SSIS Design2:增量更新

    一般来说,ETL实现增量更新的方式有两种,第一种:记录字段的最大值,如果数据源中存在持续增加的数据列,记录上次处理的数据集中,该列的最大值:第二种是,保存HashValue,快速检查所有数据,发现异动 ...

  7. android studio增量更新

    一.概述 1.1 概念 增量更新即是通过比较 本机安装版本 和 想要安装版本 间的差异,产生一个差异安装包,不需要从官网下载并安装全量安装包,更不需要将本机已安装的版本下载,而仅仅只是安装此差异安装包 ...

  8. Android 增量更新(BSDiff / bspatch)

    Android 增量更新 BSDiff / bspatchhttp://www.daemonology.net/bsdiff/android的代码目录下 \external\bsdiff bsdiff ...

  9. 【转载】Unity 合理安排增量更新(热更新)

    原帖地址:由于我看到的那个网站发的这篇帖子很大可能是盗贴的,我就暂时不贴地址了.避免伤害原作者 原版写的有点乱,我个人修改整理了下. --------------------------------- ...

随机推荐

  1. JavaScript高程第三版笔记-面向对象编程

    之前有篇博客曾提到过一点js的面向对象编程:js面向对象编程. 这里就结合js高程详细剖析一下javascript的面向对象编程. 前序: 1⃣️Object.defineProperty() var ...

  2. 【URL 的编码、解码】

    工具类 /** * URLEncodeTest.java * weixinTest * * Function: TODO * * ver date author * ───────────────── ...

  3. java:sso(单点登录(single sign on),jsp文件动静态导入方式,session跨域)

    1.jsp文件导入: 2.session跨域: 3.sso(单点登录(single sign on): sso Maven Webapp: LoginController.java: package ...

  4. WebApiTestClient

    1.WebApiTestClient组件作用主要有以下几个: (1).将WebApi的接口放到了浏览器里面,以可视化的方式展现出来,比如我们通过http://localhost:8080/Help这个 ...

  5. idea退出提醒 打开

    有时候会误点下面的勾选框,导致以后直接退出,没有提示,很不方便,经常误点关闭,再次打开又要等很久 如何设置回来? File-Setting-Appearance&Beha-System Set ...

  6. Lua for Mac环境搭建

    1⃣️在Mac上安装Lua的运行环境再简单不过了,如果你的Mac Terminal上安装了Homebrew的话,只需要键入`brew install lua`即可. longsl-mac:~ long ...

  7. collections(python常用内建模块)

    文章来源:https://www.liaoxuefeng.com/wiki/897692888725344/973805065315456 collections collections是Python ...

  8. 【Linux开发】编写属于你的第一个Linux内核模块

    曾经多少次想要在内核游荡?曾经多少次茫然不知方向?你不要再对着它迷惘,让我们指引你走向前方-- 内核编程常常看起来像是黑魔法,而在亚瑟 C 克拉克的眼中,它八成就是了.Linux内核和它的用户空间是大 ...

  9. 【Linux开发】linux设备驱动归纳总结(五):2.操作硬件——IO内存

    linux设备驱动归纳总结(五):2.操作硬件--IO内存 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ...

  10. [Python3] 037 函数式编程 装饰器

    目录 函数式编程 之 装饰器 Decrator 1. 引子 2. 简介 3. 使用 函数式编程 之 装饰器 Decrator 1. 引子 >>> def func(): ... pr ...