首页 > 移动平台 > 详细

Hive history date mapping

时间:2015-03-27 08:44:31      阅读:402      评论:0      收藏:0      [点我收藏+]

技术分享

Hive history table mapping

create table fdl_family as
select * from 
(select ‘acc1‘ as account,‘family1‘ as family,‘2010-01-01‘ as effect_date from nums where num<1
union all
select ‘acc1‘ as account ,‘family2‘ as family,‘2013-01-01‘ as effect_date from nums where num<1
)  a;

create table fdl_family_period as 
select *,effect_date as start_date, coalesce(lead(effect_date) over(partition by account order by effect_date),‘9999-12-31‘) as end_date from fdl_family ;

alter table fdl_family_period change nextdate end_date string;
select * from fdl_family_period ;

--hive --service hiveserver -p 10002;

create table andes_std_trans  as
select * from 
(select ‘acc1‘ as account,‘maker1‘ as maker,100 as amount,‘2012-10-11‘ as trans_date from nums where num<1
union all
select ‘acc1‘ as account ,‘maker1‘ as maker,200 as amount,‘2013-10-11‘ as trans_date from nums where num<1
)  a;

select a.*,b.family from andes_std_trans a join fdl_family_period b on a.account = b.account
where  a.trans_date between b.start_date and b.end_date;

Hive history date mapping

原文:http://www.cnblogs.com/huaxiaoyao/p/4370614.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!