Skip to content
Advertisement

query hbase like normal sql

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:

  1. Use Apache Phoenix (Recommended). It’s a powerful SQL wrapper for HBase.
  2. 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");
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement