数仓增量更新数据

数仓 资源层 增量 更新数据

select * from 库2.表1
union all
select a.* from 库1(原始数据层).表1 a
left outer join 库2(资源层).表1 b
on a.id = b.id where b.id is null;

然后根据分区字段 加载入新的分区
insert overwrite table 资源库.资源表(PARTITION(l_etl_date=‘时间’’))
select * from 初始库.初始表 as a
left join 资源库.资源表 on a.innerid = b.innerid where b.innerid is null
and etl_date>‘时间’

测试:
表stu
在这里插入图片描述
表stu2
在这里插入图片描述
select b.* from stu2 b
LEFT JOIN stu a
ON a.id = b.id
where a.id is null

在这里插入图片描述
stu相当于原始数据层
stu2相当于资源层

INSERT overwrite INTO TABLE stu
SELECT * FROM stu
UNION ALL
(select b.* from stu2 b
LEFT JOIN stu a
ON a.id = b.id
where a.id is null)
这样加载数据mysql不支持,hive支持

SELECT * FROM stu
UNION ALL
(select b.* from stu2 b
LEFT JOIN stu a
ON a.id = b.id
where a.id is null)
在这里插入图片描述在这里插入图片描述

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值