hbase表转hive

1.hive内部表的创建

CREATE TABLE ods.s01_buyer_calllogs_info_ts(

key string comment "hbase rowkey",

buyer_mobile string comment "手机号",

contact_mobile string comment "对方手机号",

call_date string comment "发生时间",

call_type string comment "通话类型",

init_type string comment "0-被叫,1-主叫",

other_cell_phone string comment "对方手机号",

place string comment "呼叫发生地",

start_time string comment "发生时间",

subtotal string comment "通话费用",

use_time string comment "通话时间(秒)"

)

STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'    

WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,record:buyer_mobile,record:contact_mobile,record:call_date,record:call_type,record:init_type,record:other_cell_phone,record:place,record:start_time,record:subtotal,record:use_time")    

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

 

 

2.hive外部表的创建

CREATE EXTERNAL TABLE ods.s10_buyer_calllogs_info_ts(

key string comment "hbase rowkey",

buyer_mobile string comment "手机号",

contact_mobile string comment "对方手机号",

call_date string comment "发生时间",

call_type string comment "通话类型",

init_type string comment "0-被叫,1-主叫",

other_cell_phone string comment "对方手机号",

place string comment "呼叫发生地",

start_time string comment "发生时间",

subtotal string comment "通话费用",

use_time string comment "通话时间(秒)"

)    

STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'    

WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,record:buyer_mobile,record:contact_mobile,record:call_date,record:call_type,record:init_type,record:other_cell_phone,record:place,record:start_time,record:subtotal,record:use_time")    

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

 

3.hive映射hbase表的列族

CREATE TABLE hbase_table_1(value map, row_key int)

STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'

WITH SERDEPROPERTIES (

"hbase.columns.mapping" = "cf:,:key"

);

INSERT OVERWRITE TABLE hbase_table_1 SELECT map(bar, foo), foo FROM pokes

WHERE foo=98 OR foo=100;

你可能感兴趣的:(报表系统)