ETL拉鏈演算法匯總大全__演算法

來源:互聯網
上載者:User

拉鏈演算法總結大全:
一、0610演算法(追加)
1、刪除倉庫表的載入日期是本次載入日期的資料,以支援重跑
delete from xxx where start_dt >=$tx_date;
2、建立暫存資料表,用於存放從源表中提取的資料
create multiset volatile table xxx;
3、向暫存資料表中插入資料,按照一定規則加工
insert into xxx select ... from xxx;
4、對於暫存資料表的資料打上時間戳記直接插入倉庫表中
insert into xxx select ... from xxx;
二、0611演算法(全刪全插)
1、將倉庫表中主鍵處於源表的欄位記錄刪除
delete from xxx where (id) in (select id  from xxx);
2、將源表的所有資料直接插入到倉庫表中
insert into xxx select ... from xxx;
三、0612演算法(曆史拉鏈演算法)
1、刪除倉庫表的載入日期是本次載入日期的資料,用於支援重跑
delete from xxx where start_dt >= $tx_date;
2、修改倉庫表的結束日期欄位,作用是把結束日期大於載入日期並且不是最大日期的資料的結束日期置為最大日期,使其有效
update set end_dt=$max_dt where end_dt >= $tx_date and end_dt <> max_dt;
3、建立暫存資料表用於存放從源表中提取的資料
create multiset volatile table new;
4、建立臨時增量表用於存放增量資料
create multiset volatile table inc;
5、根據一定的規則向暫存資料表中載入源表資料,根據需求而定
insert into new select ... from  xxx where ...;
6、用暫存資料表的資料與倉庫表資料作對比,將新增和更改的資料存入增量表中
insert into inc select ... from new where .. not in ..;
7、對所有在增量表的並且是有效資料進行關鏈處理
update xxx set end_dt=$tx_date where ...;
8、對所有處於增量表中的資料進行拉新鏈處理
insert into xxx select ... from inc;
四、0614(帶刪除的曆史拉鏈演算法)
1、刪除倉庫表的載入日期是本次載入日期的資料,用於支援重跑
delete from xxx where start_dt >= $tx_date;
2、修改倉庫表的結束日期欄位,作用是把結束日期大於載入日期並且不是最大日期的資料的結束日期置為最大日期,使其有效
update set end_dt=$max_dt where end_dt >= $tx_date and end_dt <> max_dt;
3、建立暫存資料表用於存放從源表中提取的資料
create multiset volatile table new;
4、建立臨時增量表用於存放增量資料,這裡會存放源系統物理刪除的資料並使用min_date進行標識
create multiset volatile table inc;
5、根據一定的規則向暫存資料表中載入源表資料,根據需求而定
insert into new select ... from  xxx where ...;
6、用暫存資料表的資料與倉庫表資料作對比,將新增和更改的資料存入增量表中
insert into inc select ... from new where .. not in ..;
7、用倉庫表的有效資料主鍵跟暫存資料表資料主鍵作對比 in 倉庫表 not in 暫存資料表的即為源系統物理刪除的欄位,將其end_dt用min_date標識存入增量表(這條資料來源於倉庫)
insert into .. select ... from where end_dt=$max_date and etl_job_num=920 and (agt_num,agt_modif_num) not in (select agt_num,agt_modif_num from new)
8、對所有在增量表的並且是有效資料進行關鏈處理
update xxx set end_dt=$tx_date where ...;
9、對所有處於增量表中的並且end_dt標識不是min_date的資料進行拉新鏈處理
insert into xxx select ... from inc where end_dt <> $min_date;
五、0616(經濟型曆史拉鏈演算法)
1、設定事無層級為RU優先於其他事務
set session characteristics as transaction isolation level ru
2、建立暫存資料表用於存放從源表中提取的資料
create multiset volatile table new
3、建立增量表用於存放增量資料 這裡只會存放新增個更改的資料
create multiset volatile table inc
4、建立刪除表用於存放邏輯刪除資料 帶有特殊標識的邏輯刪除資料
create multiset volatile table del
5、向暫存資料表中插入資料按照一定的載入規則
insert into new 
6、用暫存資料表的資料與倉庫表資料作對比將新增的更改的資料存入增量表中
insert into inc select ... from new 
7、將源表資料中有特殊標識的(一般為end_dt=min_date)存入刪除表中
insert into del select .. from new where end_dt=min_date
8、對所有在增量表和刪除表中資料進行關鏈處理
update xxx set end_dt=$tx_date where ...
9、對所有在增量表中的資料拉新鏈除了指定項
insert into xxx select ... from inc where seq_num <>''
六、0613(邏輯刪除的曆史拉鏈演算法)
0613和0616幾乎一樣,除了最後一步
9、對所有在增量表中的資料拉新鏈

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.