intergrate hbase-1.2.4 into hive-2.1.1

1) external table in hbase


hbase> create ' hvtohbase', 'cf1'


hive >create table ccc(foo int,bar string) row format delimited fields terminated by '\t' lines terminated by '\n' stored as textfile;


hive > CREATE external TABLE hvtohbase(key int, value string)    
   STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'  
    WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val")   

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


hive >load data local inpath 'back.txt' overwrite into table ccc;


hive >insert overwrite table hvtohbase select * from ccc where foo=1;


2) internal table in hive


hive>create   table page_views(tracktime string,url string,sessionid string,referer string,ip string,enduserid  string,cityid string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'  
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:url,info:sessionid,info:referer,info:ip,info:enduserid,info:cityid")  
TBLPROPERTIES ("hbase.table.name" = "page_views");


create table page_views_txt (
id                         string ,
url                        string ,
referer                    string ,
keyword                    string ,
type                       string ,
guid                       string ,
pageId                     string ,
moduleId                   string ,
linkId                     string ,
attachedInfo               string ,
sessionId                  string ,
trackerU                   string ,
trackerType                string ,
ip                         string ,
trackerSrc                 string ,
cookie                     string ,
orderCode                  string ,
trackTime                  string ,
endUserId                  string ,
firstLink                  string ,
sessionViewNo              string ,
productId                  string ,
curMerchantId              string ,
provinceId                 string ,
cityId                     string )  
PARTITIONED BY (ds string,hour string)  

ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t';
load data local inpath '/home/[email protected]/download/2015082818' into table page_views_txt PARTITION (ds='20150828',hour='18');


insert into table page_views select tracktime ,url ,sessionid ,referer ,ip ,enduserid  ,cityid  from page_views_txt where ds='20150828' and hour='18' limit 10;

3)notice:


a)

//val trackRdd = sc.textFile("/user/hive/warehouse/page_views")  //page_views is externally stored in hbase ,can not be read as textFile


// val trackRdd = sc.textFile("/user/hive/warehouse/hvtohbase")  //  hvtohbase ()externally stored in hbase , not working 

 
  




你可能感兴趣的:(大数据)