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. 虚拟环境mkvirtualenv

    python虚拟环境mkvirtualenv使用   安装virtualenvwrapper  pip install virtualenvwrapper   修改默认虚拟环境目录: 环境变量中新建: ...

  2. maven的基本使用

    安装: 1.下载maven http://maven.apache.org/ 2.将maven包解压并放置到安装目录 3.添加环境变量M2_HOME,path当中添加;%M2_HOME%\bin; 4 ...

  3. 实验一part1.1 1.2

    #include<stdio.h> int main() { printf("201983270526\n"); printf("Hello Mars!&qu ...

  4. 40G传输技术浅析

    采用40G传输技术给运营商带来的好处 - 同样的带宽,更低的硬件成本.由于目前的光电器件工艺已臻于成熟,质量更为可靠,使40G的商用具有了必要的前提.同样是40G容量,器件的数量大致只有4个10G光接 ...

  5. PJzhang:ping命令的基本用法

    猫宁!!! 参考链接:https://www.cnblogs.com/diantong/p/9626751.html http://aiezu.com/article/linux_ping_comma ...

  6. webdriervAPI(窗口截图)

    from  selenium  import  webdriver driver  =  webdriver.Chorme() driver.get("http://www.baidu.co ...

  7. 代码: 0x80131500 win10应用商店崩溃了

    网上搜索大部分认同的结果如下 1.打开“运行”输入 inetcpl.cpl (“WINDOWS”+“R”键,输入 inetcpl.cpl亦可) 2.点开高级往下拉,勾上"使用TLS 1.2& ...

  8. Minimum Score Triangulation of Polygon

    Given N, consider a convex N-sided polygon with vertices labelled A[0], A[i], ..., A[N-1] in clockwi ...

  9. 批量删除Maven本地仓库中未下载完成的jar包(不完整的jar包)

    1.删除repository库目录下所有后缀名是.lastUpdated的文件 2.进入maven本地仓库地址: CMD进入windows的路径(或在仓库目录的地址栏直接输入CMD,回车自动打开); ...

  10. spark教程(14)-共享变量

    spark 使用的架构是无共享的,数据分布在不同节点,每个节点有独立的 CPU.内存,不存在全局的内存使得变量能够共享,驱动程序和任务之间通过消息共享数据 举例来说,如果一个 RDD 操作使用了驱动程 ...