Hbase包含key映射为hive表

1,语法apache

CREATE EXTERNAL TABLE hive 代表 (hive字段名称1 数据类型, hive字段名称2 数据类型)app

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

WITH SERDEPROPERTIES ( 和 hive 字段名称1 对应的 hbase 的列名 ,和 hive 字段名称2 对应的 hbase 的列名)code

TBLPROPERTIES("hbase.table.name" = "hbase 的代表");hadoop

当须要映射hbase的key 的时候参考下面的方式string

CREATE EXTERNAL TABLE hive 代表 (hive字段名称1(须要映射hbase的能够) 数据类型, hive字段名称2 数据类型)table

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

WITH SERDEPROPERTIES ( 'hbase.columns.mapping'=":key,和 hive 字段名称2 对应的 hbase 的列名)date

TBLPROPERTIES("hbase.table.name" = "hbase 的代表");map

eg:

CREATE EXTERNAL TABLE dim_sys_date(
`date_key` string , 
`date_seed` date ,
`day_of_week` int,
`day_of_week_desc` string,
`day_of_month` int,
`day_of_year` int ,
`is_last_day_of_month` int ,
`week_of_year` int,
`week_of_year_desc` string,
`year_week` int,
`first_day_of_week` date,
`last_day_of_week` date,
`month` int,
`month_desc` string,
`year_month` int,
`quarter` int,
`quarter_desc` string,
`year_quarter` string,
`year` string,
`is_weekend` string
) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
WITH SERDEPROPERTIES ( 
'hbase.columns.mapping'=":key,
calendar:dateSeed,
calendar:dayOfWeek,
calendar:dayOfWeekDesc,
calendar:dayOfMonth,
calendar:dayOfYear,
calendar:isLastDayOfMonth,
calendar:weekOfYear,
calendar:weekOfYearDesc,
calendar:yearAndWeek,
calendar:firstDayOfWeek,
calendar:lastDayOfWeek,
calendar:month,
calendar:monthDesc,
calendar:yearAndMonth,
calendar:quarter,
calendar:quarterOfDesc,
calendar:yearAndQuarter,
calendar:year,
calendar:isWeekend
"
) 
TBLPROPERTIES("hbase.table.name" = "dim_sys_date");
相关文章
相关标签/搜索