hive建立内部表映射hbase_hive中创建hbase映射表

本文档演示了如何在Hive中使用CREATE TABLE语句创建一个外部表,该表映射到HBase的USER表。详细步骤包括创建外部表的定义,指定HBase的列映射,并将Hive表中的指定字段导出到本地目录。Hive表的结构和HBase的映射关系清晰地展示了数据在两个系统间的交互方式。
摘要由CSDN通过智能技术生成

use cmpay_credit;

-- Create external table for USER in HBase

drop table if exists ex_user;

create external table if not exists ex_user(

rowid string,

account_level string,

name string,

boss_brand string,

credit_level string,

birthday string,

cmpay_id string,

fst_consume_day string,

bind_card_type string,

score_identity string,

is_validate string,

is_black_list string,

lastest_active_date string,

score_history_credit string,

register_date string,

score_time string,

user_id string,

admiss_date string,

score_behavior string,

score_social_cycle string,

sex string,

score_performance string,

is_real string,

mobile_no string,

bind_card_amount string,

cur_year_fst_login_day string,

score_total string

) ROW FORMAT SERDE 'org.apache.hadoop.hive.hbase.HBaseSerDe'

stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'

WITH SERDEPROPERTIES(

"hbase.columns.mapping"=":key, cf:account_level, cf:name, cf:boss_brand,

cf:credit_level, cf:birthday, cf:cmpay_id, cf:fst_consume_day,

cf:bind_card_type, cf:score_identity, cf:is_validate, cf:is_black_lisT,

cf:lastest_active_date, cf:score_history_credit, cf:register_date,

cf:score_time, cf:user_id, cf:admiss_date, cf:score_behavior,

cf:score_social_cycle, cf:sex, cf:score_performance, cf:is_real, cf:mobile_no,

cf:bind_card_amount, cf:cur_year_fst_login_day, cf:score_total")

TBLPROPERTIES( "hbase.table.name"="USER");

-- export records of specified fields from ex_user

insert overwrite local directory '/tmp/user_score'

row format delimited fields terminated by ',' select mobile_no, score_behavior,

score_history_credit, score_identity, score_performance, score_social_cycle,

score_total from ex_user;

注意一点

rowid string,

对应key

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值