hive增量更新

2021-08-20 20:52:06 字數 557 閱讀 2143

很多資料需要進行更新,如使用者資訊修改。hive0.11之後開始支援update和delete。但是hive頻繁更新與hive的設計原則相反,並且hive增量更新很緩慢。為實現增量更新,我們可以採用union all進行關聯或在乙個分割槽表中求最新的日期的資料。

select b.id,b.content,b.update_date from (

select a.*,row_number() over (distribute by id sort by update_date) as rn

from (select id,content,update_date from t1 union all select id,content,update_date from t2) a

) bwhere b.rn=1;

或者select b.id,b.content,b.update_date from 

(select a.* ,row_number() over(distribute by id sort by update_date) as rn from a) b

where b.rn=1;

hive 實現增量更新

保險公司有乙個表記錄客戶的資訊,其中包括有客戶的id,name和age 為了演示只列出這幾個字段 建立hive的表 create table customer id int,age tinyint,name string partitioned by dt string row format del...

Hive中實現增量更新

保險公司有乙個表記錄客戶的資訊,其中包括有客戶的id,name和age 為了演示只列出這幾個字段 建立hive的表 create table customer id int,age tinyint,name string partitioned by dt string row format del...

Hive增量更新方案

hive增量更新方案 方案一 總結出來業界可行方案 1 hive原始表提前規劃好以時間分割槽,初始化裝載源庫記錄為base table 最新資料 2 每個相關表都會有乙個timestamp列,對每一行操作做了修改,都會重置這列timestamp為當前時間戳 3 新增資料通過sqoop 支援當天抽取 ...