How to create external table for hbase
hbase, hive
Solution
Create table in Hbase shell
`create 'hbase_2_hive_names', 'id', 'name', 'age'`
Load data into Hbase (the input file must be in HDFS)
`export HADOOP_CLASSPATH=$(/usr/local/hbase/bin/hbase classpath);$HADOOP_HOME/bin/hadoop jar /usr/local/hbase/hbase-0.94.1.jar importtsv -Dimporttsv.columns=HBASE_ROW_KEY,id:id,name:fn,name:ln,age:age hbase_2_hive_names /var/data/samples/names.tsv`
Create external table in Hive shell
`CREATE EXTERNAL TABLE hbase_hive_names(hbid INT, id INT, fn STRING, ln STRING, age INT) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,id:id,name:fn,name:ln,age:age") TBLPROPERTIES("hbase.table.name" = "hbase_2_hive_names");`
Problem
I am able to create external tables in hive of HBase, now i have a requirement to create an external table which is having variable columns, which means the columns in HBase are not fixed for the particular table, the no of columns and can be created dynamically at the time of data insertion, what should be the approach for handling such kind of situation. Summery : How to create external tables in hive when the no of columns are not fixed in HBase table. Thanks in advance.