create the file with following data
-----------------------------------
1,abc,40000,a$b$c,pf#500$epf#200,hyd$ap$500001
2,def,3000,d$f,pf#500,bang$kar$600038
create logical table in hive and load data into that tabel
-----------------------------------------------------------
create table logical_table(id int,name string,sal bigint,sub array<string>,dud map<string,int>,addr struct<city:string,state:string,pin:bigint>) row format delimited fields terminated by ',' collection items terminated by '$' map keys terminated by '#';
load data local inpath '/home/hadoop/work/hive_input' overwrite into table logical_table;
create hbase table in hive
---------------------------
[during hbase and hive integration we have to set auxilary path to hive in this path five main jar should be added]
1.hive-hbase-handler-[hive version].jar
2.hbase-[hbase version].jar
3.zookeper-[running version].jar
4.guava-[version].jar
5.protobuf-java-[version comes with hbase/lib].jar
$HIVE_HOME/bin/hive --auxpath /home/hadoop/work/hive-0.10.0/lib/hive-hbase-handler-0.10.0.jar,/home/hadoop/work/hive-0.10.0/lib/guava-r09.jar,/home/hadoop/work/hive-0.10.0/lib/zookeeper-3.4.5.jar,/home/hadoop/work/hive-0.10.0/lib/hbase-0.94.8.jar,/home/hadoop/work/hive-0.10.0/lib/protobuf-java-2.4.0a.jar; --hiveconf hbase.zookeeper.quorum=localhost
create table hive_hbase_table(key int,name string,sal bigint,sub array<string>,dud map<string,int>,addr struct<city:string,state:string,pin:bigint>) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES("hbase.columns.mapping" = ":key,cf1:name,cf1:sal,cf1:sub,cf1:dud,cf1:addr") TBLPROPERTIES ("hbase.table.name" = "hibehbasetable");
insert overwrite table hive_hbase_table select * from logical_table;
-----------------------------------
1,abc,40000,a$b$c,pf#500$epf#200,hyd$ap$500001
2,def,3000,d$f,pf#500,bang$kar$600038
create logical table in hive and load data into that tabel
-----------------------------------------------------------
create table logical_table(id int,name string,sal bigint,sub array<string>,dud map<string,int>,addr struct<city:string,state:string,pin:bigint>) row format delimited fields terminated by ',' collection items terminated by '$' map keys terminated by '#';
load data local inpath '/home/hadoop/work/hive_input' overwrite into table logical_table;
create hbase table in hive
---------------------------
[during hbase and hive integration we have to set auxilary path to hive in this path five main jar should be added]
1.hive-hbase-handler-[hive version].jar
2.hbase-[hbase version].jar
3.zookeper-[running version].jar
4.guava-[version].jar
5.protobuf-java-[version comes with hbase/lib].jar
$HIVE_HOME/bin/hive --auxpath /home/hadoop/work/hive-0.10.0/lib/hive-hbase-handler-0.10.0.jar,/home/hadoop/work/hive-0.10.0/lib/guava-r09.jar,/home/hadoop/work/hive-0.10.0/lib/zookeeper-3.4.5.jar,/home/hadoop/work/hive-0.10.0/lib/hbase-0.94.8.jar,/home/hadoop/work/hive-0.10.0/lib/protobuf-java-2.4.0a.jar; --hiveconf hbase.zookeeper.quorum=localhost
create table hive_hbase_table(key int,name string,sal bigint,sub array<string>,dud map<string,int>,addr struct<city:string,state:string,pin:bigint>) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES("hbase.columns.mapping" = ":key,cf1:name,cf1:sal,cf1:sub,cf1:dud,cf1:addr") TBLPROPERTIES ("hbase.table.name" = "hibehbasetable");
insert overwrite table hive_hbase_table select * from logical_table;
No comments:
Post a Comment