I know Hbase
is not like normal SQL
.
But is it possible to query Hbase something like this?
select row-key from Table where cf:first="ram" and cf:middle="leela" and cf:last="ban"; // ram(first name) leela(middle name) ban(last name)
Advertisement
Answer
There are two ways of doing it:
- Use Apache Phoenix (Recommended). It’s a powerful SQL wrapper for HBase.
- Use Apache Hive. Hive can create an ‘external table’ using HiveQL:
CREATE EXTERNAL TABLE employees ( empid int, ename String ) ROW FORMAT DELIMITED COLLECTION ITEMS TERMINATED BY '#' STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf:ename") TBLPROPERTIES ("hbase.table.name" = "employees");