将HBase中的表数据导入到hive中

--------------------user_friend-----------------
创建hb_user_friend外部表:

create external table events.hb_user_friend(
row_key string
,user_id string
,friend_id string) 
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
with serdeproperties('hbase.columns.mapping'=':key,
uf:userid,
uf:friendid') 
tblproperties('hbase.table.name'='events_db:user_friend');

创建user_friend内部表:

create table user_friend
stored as ORC AS
select * from hb_user_friend;

------------------------------event_attendee-----------------------------
创建hb_event_attendee外部表:

create external table events.hb_event_attendee(row_key string,event_id string,user_id string,attend_type string) 
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
with serdeproperties('hbase.columns.mapping'=':key,euat:eventid,euat:userid,euat:state') 
tblproperties('hbase.table.name'='events_db:event_attendee');

创建event_attendee内部表:

create table event_attendee
stored as ORC AS
select * from hb_event_attendee;

------------------------------events---------------------------------
创建hb_events外部表:

create external table events.hb_events(
event_id string,
start_time string,
city string,
state string,
zip string,
country string,
lat string,
lng string,
user_id string,
common_words string) 
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
with serdeproperties('hbase.columns.mapping'=':key,
creator:user_id,
schedule:start_time,
location:city,
location:state,
location:zip,
location:country,
location:lat,
location:lng,
remark:common_words') 
tblproperties('hbase.table.name'='events_db:events');

创建events内部表:

create table events
stored as ORC AS
select * from hb_events;

-----------------------------------train---------------------------------
创建hb_train外部表:

create external table events.hb_train(row_key string,
user_id string,
event_id string,
invited string,
timestamp string,
interested string,
not_interested string
) 
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
with serdeproperties('hbase.columns.mapping'=':key,
eu:user,
eu:event,
eu:invited,
eu:timestamp,
eu:interested,
eu:not_interested
') 
tblproperties('hbase.table.name'='events_db:train');

创建train内部表:

create table train
stored as ORC AS
select * from hb_train;

----------------------users------------------------
创建hb_users外部表:

create external table events.hb_users(
user_id string,
birthyear string,
gender string,
locale string,
location string,
timezone string,
joined_at string
) 
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
with serdeproperties('hbase.columns.mapping'=':key,
profile:locale,
profile:birthyear,
region:gender,
registration:joinedAt,
region:location,
region:timezone
') 
tblproperties('hbase.table.name'='events_db:users');

创建users内部表:

create table users
stored as ORC AS
select * from hb_users;
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值