拉链表理解分析

本文介绍了拉链表在数据仓库中的应用,用于保存历史记录,以解决大数据存储问题。通过示例展示了如何使用Hive对订单表进行分区存储,并在数据变更时更新拉链表,确保数据完整性和追溯性。通过比较ods_orders和dw_orders表,更新和新增数据,实现了高效的数据管理策略。

一、概述
拉链表是一种满足生产需求的表,主要用于历史记录。如下图
在这里插入图片描述
最后两列即为拉链,记录数据的生效时间与失效时间,同一个orderid的失效时间与下一次生效时间总是互相对应。
在数据仓库的设计过程中,由于一些表的数据量很大,即使压缩后仍有1~200G,加之hdfs储存备份副本,仍会占用大量的存储空间。
当用户更改状态时,表内数据(昵称、手机号等)可以会被一些操作如update覆盖掉,导致数据丢失。
有时需要统计每一天或者每个节点的状态数据、快照等。
部分表中的记录变化的比例和频率不是很大。

二、实例
这是我们每一天的数据表orders 。
在这里插入图片描述
这是贴源层的ods_orders表。

在这里插入图片描述
这是要求的数据表
在这里插入图片描述

========================================================
创建2021/11/25(第一天)的orders表

create table orders(
orderid int,id int, name string,status string,
create_date string,modified_date string 
)
row format delimited fields 
terminated by '\t';

将建好的2021-11-25的orders.txt文件导入orders表

select * from orders;

1	1008	cq	创建	2021/11/25	2021/11/25
2	3023	zm	创建	2021/11/25	2021/11/25
3	3585	yy	创建	2021/11/25	2021/11/25

创建ods_orders表

create table ods_orders(
orderid int,id int, name string,status string,
create_date string,modified_date string
)
partitioned by (date string)
row format delimited fields terminated by '\t';

将orders表数据导入(增加date分区)

insert overwrite table ods_orders partition(day='2021-11-25')
select * from orders;

select * from ods_orders;

1	1008	cq	创建	2021/11/25	2021/11/25	2021-11-25
2	3023	zm	创建	2021/11/25	2021/11/25	2021-11-25
3	3585	yy	创建	2021/11/25	2021/11/25	2021-11-25

创建dw_orders

create table dw_orders(
orderid int,id int, name string,status string,
create_date string,modified_date string,
start_date string,end_date string
)row format delimited fields terminated by '\t';

将ods_orders表数据导入(增加start_date和end_date列)

insert overwrite table dw_orders
select orderid,id,name,status,create_date,
modified_date,create_date,'9999-12-31' 
from ods_orders
where date='2021-11-25';

select * from dw_orders;

1	1008	cq	创建	2021/11/25	2021/11/25	2021/11/25	9999-12-31
2	3023	zm	创建	2021/11/25	2021/11/25	2021/11/25	9999-12-31
3	3585	yy	创建	2021/11/25	2021/11/25	2021/11/25	9999-12-31

这些就是2021/11/25日记录的数据

将建好的2021-11-26的orders.txt文件导入orders表

select * from orders;

1	1008	cq	创建	2021/11/25	2021/11/25
2	3023	zm	创建	2021/11/25	2021/11/25
3	3585	yy	创建	2021/11/25	2021/11/25
1	1008	cq	支付	2021/11/25	2021/11/26
2	3023	zm	支付	2021/11/25	2021/11/26
4	3297	th	创建	2021/11/26	2021/11/26
5	6824	mm	创建	2021/11/26	2021/11/26

将2021-11-26新增的数据导入ods_orders表(分区为2021-11-26)

insert overwrite table ods_orders partition(date='2021-11-26')
select * from orders
where modified_date='2021/11/26';

查看表

 select * from ods_orders;

1	1008	cq	创建	2021/11/25	2021/11/25	2021-11-25
2	3023	zm	创建	2021/11/25	2021/11/25	2021-11-25
3	3585	yy	创建	2021/11/25	2021/11/25	2021-11-25
1	1008	cq	支付	2021/11/25	2021/11/26	2021-11-26
2	3023	zm	支付	2021/11/25	2021/11/26	2021-11-26
4	3297	th	创建	2021/11/26	2021/11/26	2021-11-26
5	6824	mm	创建	2021/11/26	2021/11/26	2021-11-26

查看分区

show partitions ods_orders;

date=2021-11-25
date=2021-11-26

将修改内容导入dw_orders表
注:可以将新的dw_orders表分为两部分
一部分是更新已有的发生更改的数据
另一部分是添加新增的数据
最终结果为将两部分表拼接到一起并进行排序

第一部分:
根据已修改后的ods_orders表与未修改的dw_orders表进行比较,
得出更改的数据(因为只考虑更新数据,故以dw_orders为主采用left join)

select
t1.orderid,
t1.id,
t1.name,
t1.status,
t1.create_date,
t1.modified_date,
t1.start_date,
case 
	when t2.orderid is not null and t1.end_date>'2021/11/26' 
	then '2021/11/26' else t1.end_date 
end end_date
from dw_orders t1
left join 
(select 
orderid ,modified_date 
from ods_orders 
where date='2021-11-26') t2
on t1.orderid=t2.orderid;

1	1008	cq	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
2	3023	zm	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
3	3585	yy	创建	2021/11/25	2021/11/25	2021/11/25	9999-12-31

第二部分:
新增数据修改好start和end日期即可

select 
orderid,
id,
name,
status,
create_date,
modified_date,
modified_date start_date,
'9999-12-31' end_date
from ods_orders 
where date='2021-11-26';

1	1008	cq	支付	2021/11/25	2021/11/26	2021/11/26	9999-12-31
2	3023	zm	支付	2021/11/25	2021/11/26	2021/11/26	9999-12-31
4	3297	th	创建	2021/11/26	2021/11/26	2021/11/26	9999-12-31
5	6824	mm	创建	2021/11/26	2021/11/26	2021/11/26	9999-12-31

最终 合并两张表 并排序即可

select 
t.orderid,t.id,t.name,t.status,t.create_date,
t.modified_date,t.start_date,t.end_date from 
(
select
t1.orderid,
t1.id,
t1.name,
t1.status,
t1.create_date,
t1.modified_date,
t1.start_date,
case 
	when t2.orderid is not null and t1.end_date>'2021/11/26' 
	then '2021/11/26' else t1.end_date 
end end_date
from dw_orders t1
left join 
(select 
orderid ,modified_date 
from ods_orders 
where date='2021-11-26') t2
on t1.orderid=t2.orderid
union all
select 
orderid,
id,
name,
status,
create_date,
modified_date,
modified_date start_date,
'9999-12-31' end_date
from ods_orders 
where date='2021-11-26'
) as t
order by orderid,start_date;

1	1008	cq	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
1	1008	cq	支付	2021/11/25	2021/11/26	2021/11/26	9999-12-31
2	3023	zm	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
2	3023	zm	支付	2021/11/25	2021/11/26	2021/11/26	9999-12-31
3	3585	yy	创建	2021/11/25	2021/11/25	2021/11/25	9999-12-31
4	3297	th	创建	2021/11/26	2021/11/26	2021/11/26	9999-12-31
5	6824	mm	创建	2021/11/26	2021/11/26	2021/11/26	9999-12-31

将这些数据插入dw_orders表

insert overwrite table dw_orders
select 
t.orderid,t.id,t.name,t.status,t.create_date,
t.modified_date,t.start_date,t.end_date from 
(
select
t1.orderid,
t1.id,
t1.name,
t1.status,
t1.create_date,
t1.modified_date,
t1.start_date,
case 
	when t2.orderid is not null and t1.end_date>'2021/11/26' 
	then '2021/11/26' else t1.end_date 
end end_date
from dw_orders t1
left join 
(select 
orderid ,modified_date 
from ods_orders 
where date='2021-11-26') t2
on t1.orderid=t2.orderid
union all
select 
orderid,
id,
name,
status,
create_date,
modified_date,
modified_date start_date,
'9999-12-31' end_date
from ods_orders 
where date='2021-11-26'
) as t
order by orderid,start_date;

select * from dw_orders;

1	1008	cq	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
1	1008	cq	支付	2021/11/25	2021/11/26	2021/11/26	9999-12-31
2	3023	zm	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
2	3023	zm	支付	2021/11/25	2021/11/26	2021/11/26	9999-12-31
3	3585	yy	创建	2021/11/25	2021/11/25	2021/11/25	9999-12-31
4	3297	th	创建	2021/11/26	2021/11/26	2021/11/26	9999-12-31
5	6824	mm	创建	2021/11/26	2021/11/26	2021/11/26	9999-12-31

这些就是2021/11/26日记录的数据
由于后面日期的原理与此处类似后续日期数据不做解释只填写代码及结果

select * from orders;

1	1008	cq	创建	2021/11/25	2021/11/25
2	3023	zm	创建	2021/11/25	2021/11/25
3	3585	yy	创建	2021/11/25	2021/11/25
1	1008	cq	支付	2021/11/25	2021/11/26
2	3023	zm	支付	2021/11/25	2021/11/26
4	3297	th	创建	2021/11/26	2021/11/26
5	6824	mm	创建	2021/11/26	2021/11/26
1	1008	cq	发货	2021/11/25	2021/11/27
3	3585	yy	支付	2021/11/25	2021/11/27
5	6824	mm	支付	2021/11/26	2021/11/27
6	2022	kk	创建	2021/11/27	2021/11/27
7	2303	tf	创建	2021/11/27	2021/11/27

insert overwrite table ods_orders partition(date='2021-11-27')
select * from orders
where modified_date='2021/11/27';

select * from ods_orders;

1	1008	cq	创建	2021/11/25	2021/11/25	2021-11-25
2	3023	zm	创建	2021/11/25	2021/11/25	2021-11-25
3	3585	yy	创建	2021/11/25	2021/11/25	2021-11-25
1	1008	cq	支付	2021/11/25	2021/11/26	2021-11-26
2	3023	zm	支付	2021/11/25	2021/11/26	2021-11-26
4	3297	th	创建	2021/11/26	2021/11/26	2021-11-26
5	6824	mm	创建	2021/11/26	2021/11/26	2021-11-26
1	1008	cq	发货	2021/11/25	2021/11/27	2021-11-27
3	3585	yy	支付	2021/11/25	2021/11/27	2021-11-27
5	6824	mm	支付	2021/11/26	2021/11/27	2021-11-27
6	2022	kk	创建	2021/11/27	2021/11/27	2021-11-27
7	2303	tf	创建	2021/11/27	2021/11/27	2021-11-27

show partitions ods_orders;

date=2021-11-25
date=2021-11-26
date=2021-11-27

insert overwrite table dw_orders
select 
t.orderid,t.id,t.name,t.status,t.create_date,
t.modified_date,t.start_date,t.end_date from 
(
select
t1.orderid,
t1.id,
t1.name,
t1.status,
t1.create_date,
t1.modified_date,
t1.start_date,
case 
	when t2.orderid is not null and t1.end_date>'2021/11/27' 
	then '2021/11/27' else t1.end_date 
end end_date
from dw_orders t1
left join 
(select 
orderid ,modified_date 
from ods_orders 
where date='2021-11-27') t2
on t1.orderid=t2.orderid
union all
select 
orderid,
id,
name,
status,
create_date,
modified_date,
modified_date start_date,
'9999-12-31' end_date
from ods_orders 
where date='2021-11-27'
) as t
order by orderid,start_date;

select * from dw_orders;

1	1008	cq	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
1	1008	cq	支付	2021/11/25	2021/11/26	2021/11/26	2021/11/27
1	1008	cq	发货	2021/11/25	2021/11/27	2021/11/27	9999-12-31
2	3023	zm	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
2	3023	zm	支付	2021/11/25	2021/11/26	2021/11/26	9999-12-31
3	3585	yy	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/27
3	3585	yy	支付	2021/11/25	2021/11/27	2021/11/27	9999-12-31
4	3297	th	创建	2021/11/26	2021/11/26	2021/11/26	9999-12-31
5	6824	mm	创建	2021/11/26	2021/11/26	2021/11/26	2021/11/27
5	6824	mm	支付	2021/11/26	2021/11/27	2021/11/27	9999-12-31
6	2022	kk	创建	2021/11/27	2021/11/27	2021/11/27	9999-12-31
7	2303	tf	创建	2021/11/27	2021/11/27	2021/11/27	9999-12-31

=====================================================

select * from orders;

1	1008	cq	创建	2021/11/25	2021/11/25
1	1008	cq	支付	2021/11/25	2021/11/26
1	1008	cq	发货	2021/11/25	2021/11/27
1	1008	cq	完成	2021/11/25	2021/11/28
2	3023	zm	创建	2021/11/25	2021/11/25
2	3023	zm	支付	2021/11/25	2021/11/26
2	3023	zm	支付	2021/11/25	2021/11/28
3	3585	yy	创建	2021/11/25	2021/11/25
3	3585	yy	支付	2021/11/25	2021/11/27
4	3297	th	创建	2021/11/26	2021/11/26
4	3297	th	支付	2021/11/26	2021/11/28
5	6824	mm	创建	2021/11/26	2021/11/26
5	6824	mm	支付	2021/11/26	2021/11/27
6	2022	kk	创建	2021/11/27	2021/11/27
7	2303	tf	创建	2021/11/27	2021/11/27
7	2303	tf	支付	2021/11/27	2021/11/28
8	1024	llx	创建	2021/11/28	2021/11/28
9	2012	cc	创建	2021/11/28	2021/11/28


insert overwrite table ods_orders partition(date='2021-11-28')
select * from orders
where modified_date='2021/11/28';

select * from ods_orders;

1	1008	cq	创建	2021/11/25	2021/11/25	2021-11-25
2	3023	zm	创建	2021/11/25	2021/11/25	2021-11-25
3	3585	yy	创建	2021/11/25	2021/11/25	2021-11-25
1	1008	cq	支付	2021/11/25	2021/11/26	2021-11-26
2	3023	zm	支付	2021/11/25	2021/11/26	2021-11-26
4	3297	th	创建	2021/11/26	2021/11/26	2021-11-26
5	6824	mm	创建	2021/11/26	2021/11/26	2021-11-26
1	1008	cq	发货	2021/11/25	2021/11/27	2021-11-27
3	3585	yy	支付	2021/11/25	2021/11/27	2021-11-27
5	6824	mm	支付	2021/11/26	2021/11/27	2021-11-27
6	2022	kk	创建	2021/11/27	2021/11/27	2021-11-27
7	2303	tf	创建	2021/11/27	2021/11/27	2021-11-27
1	1008	cq	完成	2021/11/25	2021/11/28	2021-11-28
2	3023	zm	支付	2021/11/25	2021/11/28	2021-11-28
4	3297	th	支付	2021/11/26	2021/11/28	2021-11-28
7	2303	tf	支付	2021/11/27	2021/11/28	2021-11-28
8	1024	llx	创建	2021/11/28	2021/11/28	2021-11-28
9	2012	cc	创建	2021/11/28	2021/11/28	2021-11-28

show partitions ods_orders;

date=2021-11-25
date=2021-11-26
date=2021-11-27
date=2021-11-28

insert overwrite table dw_orders
select 
t.orderid,t.id,t.name,t.status,t.create_date,
t.modified_date,t.start_date,t.end_date from 
(
select
t1.orderid,
t1.id,
t1.name,
t1.status,
t1.create_date,
t1.modified_date,
t1.start_date,
case 
	when t2.orderid is not null and t1.end_date>'2021/11/28' 
	then '2021/11/28' 
	else t1.end_date 
end end_date
from dw_orders t1
left join 
(select 
orderid ,modified_date 
from ods_orders 
where date='2021-11-28') t2
on t1.orderid=t2.orderid
union all
select 
orderid,
id,
name,
status,
create_date,
modified_date,
modified_date start_date,
'9999-12-31' end_date
from ods_orders 
where date='2021-11-28'
) as t
order by orderid,start_date;

select * from dw_orders;

1	1008	cq	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
1	1008	cq	支付	2021/11/25	2021/11/26	2021/11/26	2021/11/27
1	1008	cq	发货	2021/11/25	2021/11/27	2021/11/27	2021/11/28
1	1008	cq	完成	2021/11/25	2021/11/28	2021/11/28	9999-12-31
2	3023	zm	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/26
2	3023	zm	支付	2021/11/25	2021/11/26	2021/11/26	2021/11/28
2	3023	zm	支付	2021/11/25	2021/11/28	2021/11/28	9999-12-31
3	3585	yy	创建	2021/11/25	2021/11/25	2021/11/25	2021/11/27
3	3585	yy	支付	2021/11/25	2021/11/27	2021/11/27	9999-12-31
4	3297	th	创建	2021/11/26	2021/11/26	2021/11/26	2021/11/28
4	3297	th	支付	2021/11/26	2021/11/28	2021/11/28	9999-12-31
5	6824	mm	创建	2021/11/26	2021/11/26	2021/11/26	2021/11/27
5	6824	mm	支付	2021/11/26	2021/11/27	2021/11/27	9999-12-31
6	2022	kk	创建	2021/11/27	2021/11/27	2021/11/27	9999-12-31
7	2303	tf	创建	2021/11/27	2021/11/27	2021/11/27	2021/11/28
7	2303	tf	支付	2021/11/27	2021/11/28	2021/11/28	9999-12-31
8	1024	llx	创建	2021/11/28	2021/11/28	2021/11/28	9999-12-31
9	2012	cc	创建	2021/11/28	2021/11/28	2021/11/28	9999-12-31

===================================
本文中由于时间限制 所有时间都采取固定时间写死
实际可以采用函数动态获取时间

<think> 我们正在讨论拉链的含义。根据引用内容,拉链是一种在数据仓库中用于记录历史变化的数据存储方式。它通过记录每条数据的生命周期(生效开始日期和结束日期)来避免全量存储造成的数据冗余。以下是对拉链的详细解释: 1. **核心概念**: - 拉链记录一个实体(如用户、订单等)从开始到当前状态的所有历史变化。 - 它使用两个关键日期字段:`start_date`(生效开始日期)和`end_date`(生效结束日期)来标识每条记录的有效时间范围。 - 当数据发生变化时,拉链不直接覆盖旧记录,而是通过插入新记录并更新旧记录的结束日期来保存历史。 2. **结构示例**: | 用户ID | 手机号 | 开始日期 | 结束日期 | |--------|------------|------------|------------| | 001 | 138****123 | 2023-01-01 | 2023-01-31 | | 001 | 139****456 | 2023-02-01 | 9999-12-31 | | 002 | 135****789 | 2023-01-15 | 9999-12-31 | 上中: - 用户001在2023年1月使用手机号138****123,从2月开始更换为139****456(最新记录)。 - 用户002从2023年1月15日至今未变更。 3. **优势特点**: - **节省存储**:只存储变化记录,避免每日全量快照的冗余[^1][^5]。 - **历史追溯**:可查询任意时间点的数据状态(如“2023-01-20用户001的手机号是什么?”)。 - **处理缓慢变化**:完美支持数据仓库SCD2(缓慢变化维类型2)的需求[^1]。 4. **更新逻辑**: - **新增数据**:直接插入,`start_date`=当天,`end_date`=9999-12-31[^3]。 - **修改数据**: 1. 将旧记录的`end_date`更新为变更前一天。 2. 插入新记录:`start_date`=当天,`end_date`=9999-12-31[^4]。 - **删除数据**:将当前有效记录的`end_date`更新为删除当天。 5. **查询场景**: - **查最新状态**:`WHERE end_date = '9999-12-31'` - **查历史某天状态**:`WHERE '2023-01-20' BETWEEN start_date AND end_date` ### 拉链的数学达 设拉链为集合$L$,每条记录可示为四元组: $$ L = \{ (id_i, attr_i, s_i, e_i) \mid i \in \mathbb{N} \} $$ 其中: - $attr_i$为属性值 - $s_i$为生效起始日期 - $e_i$为生效结束日期 对任意$id$,其记录需满足时间连续性: $$ \forall (id, attr_k, s_k, e_k), (id, attr_m, s_m, e_m) \in L \quad (k \neq m) $$ $$ \Rightarrow \begin{cases} e_k + 1 = s_m & \text{(时间衔接)} \\ \text{或} \quad s_m > e_k & \text{(无交集)} \end{cases} $$ ### 应用示例场景 **需求**:统计2023年1月活跃用户数 **SQL**: ```sql SELECT COUNT(DISTINCT user_id) FROM zipper_table WHERE '2023-01-01' BETWEEN start_date AND end_date ``` ### 相关问题 1. 拉链Hive中如何实现增量更新? 2. 拉链与全量快照的性能对比如何? 3. 如何处理拉链中的数据删除操作? 4. 为什么拉链通常用`9999-12-31`示当前有效记录? 5. 拉链在缓慢变化维(SCD)中有哪些变体? [^1]: 拉链概念 [^2]: Hive-拉链 [^3]: 拉链hive) [^4]: 拉链介绍,及其在Hive中如何更新 [^5]: 拉链理解分析 </think>### 📊 拉链的含义详解 拉链(Zipper Table)是数据仓库中处理**缓慢变化维度数据**的核心模型,通过记录数据的生命周期(生效开始日期和结束日期)来保存全量历史状态。其核心含义可概括为: #### 一、本质定义 1. **时间轨迹记录器** 记录一条数据从产生到消亡(或当前状态)的完整生命周期,通过两个关键字段实现: - **`start_date`**:数据生效开始日期 - **`end_date`**:数据生效结束日期(通常用`9999-12-31`示当前有效记录[^3]) 2. **动态快照优化** 不同于每日全量快照(存储冗余),拉链仅存储**变化节点**,通过时间区间还原任意时刻的数据状态[^2]。 #### 二、核心工作原理 以用户信息为例: | 用户ID | 手机号 | 开始日期 | 结束日期 | |--------|------------|------------|------------| | 001 | 138****123 | 2023-01-01 | 2023-01-31 | | 001 | 139****456 | 2023-02-01 | 9999-12-31 | | 002 | 135****789 | 2023-01-15 | 9999-12-31 | - **数据变更逻辑**: 1. 用户001在2023-02-01变更手机号: - 原记录结束日期更新为`2023-01-31` - 新增记录:开始日期=`2023-02-01`,结束日期=`9999-12-31`[^4] 2. 查询2023-01-20的用户001状态: ```sql SELECT * FROM user_zipper WHERE '2023-01-20' BETWEEN start_date AND end_date ``` 结果:`138****123`(命中第一条记录) #### 三、核心价值 1. **存储优化** - 避免每日全量存储:100万用户每日全量需存100万条,拉链仅存储变化量(如每日1%变更则只需1万条)[^5] $$ \text{存储量} \approx \text{基数} + \sum \text{变更量} \ll \text{全量快照} $$ 2. **历史追溯能力** - 可精确还原任意时间点的数据状态(如法律审计要求) - 支持分析用户行为轨迹(如手机号变更频率) 3. **处理缓慢变化数据** 完美解决数据仓库SCD2(Slowly Changing Dimension Type 2)需求[^1],即保留历史版本的变化维度。 #### 四、数据结构特点 | 字段 | 说明 | 示例值 | |-------------|-------------------------------|----------------| | 业务主键 | 用户ID/订单ID等 | 001 | | 属性字段 | 会变化的业务属性(如手机号) | 139****456 | | **start_date** | 记录生效日期(分区键常用) | 2023-02-01 | | **end_date** | 记录失效日期 | 9999-12-31 | #### 五、典型应用场景 1. **用户画像管理** 记录用户等级、手机号、住址等变更历史[^2] 2. **订单状态跟踪** 存储订单从创建、支付、发货到完成的完整生命周期 3. **金融合规审计** 满足监管要求的交易记录历史追溯 ### 🌰 拉链更新示例 **2023-03-01发生变更**: - 用户001注销(删除) - 用户003新增 - 用户002地址变更 更新后: | 用户ID | 地址 | 开始日期 | 结束日期 | |--------|------------|------------|------------| | 001 | 北京海淀 | 2023-01-01 | **2023-02-28** | ← 原记录失效 | 001 | 上海浦东 | 2023-02-01 | **2023-02-28** | ← 新增失效日期 | 002 | 广州天河 | 2023-01-15 | **2023-02-28** | ← 原记录失效 | 002 | 深圳南山 | **2023-03-01** | 9999-12-31 | ← 新地址生效 | 003 | 杭州西湖 | **2023-03-01** | 9999-12-31 | ← 新增用户 > 通过`end_date`的连锁更新,形成连续的“拉链”结构[^5]。 --- ### ❓ 相关问题 1. 拉链Hive中如何实现增量更新? 2. 拉链与全量快照的查询性能对比如何? 3. 如何处理拉链中的数据删除操作? 4. 为什么拉链通常用`9999-12-31`示当前有效记录? 5. 拉链在缓慢变化维(SCD)中有哪些变体? [^1]: 拉链概念 [^2]: Hive-拉链 [^3]: 拉链hive) [^4]: 拉链介绍,及其在Hive中如何更新 [^5]: 拉链理解分析
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值