How do I access an HBase table in Hive & vice versa?

As a developer, I created an HBase table for our project, importing data from an existing MySQL table using sqoop job . The problem is that our team of data analysts is familiar with the MySQL syntax, so they can easily query the HIVE table. For them, I need to expose the HBase table in HIVE. I do not want to duplicate data by re-populating the data in HIVE. In addition, data duplication may have problems of consistency in the future.

Can I open an HBase table in HIVE without duplicating data ? If so, how do I do this? Also, if the data I insert/update/delete in my HBase table is updated, will the data be displayed in HIVE without any problems?

Sometimes our analytic data group creates a table and populates the data in HIVE. Can I provide them with HBase? If so, how?

+6
source share
1 answer

HBase-Hive Integration:

Creating an external table in hive for an HBase table allows you to query HBase data o query in Hive without the need for duplicate data. You can simply update or delete data from the HBase table, and you can also view the modified table in Hive.

Example:

You have an hbase table with id , name and email columns.

An example of an external table command for a hive:

 CREATE EXTERNAL TABLE hivehbasetable(key INT, id INT, username STRING, password STRING, email STRING) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,id:id,name:username,name:password,email:email") TBLPROPERTIES("hbase.table.name" = "hbasetable"); 

For more information on Hive-Hbase integration, see here.

+6
source

Source: https://habr.com/ru/post/986832/


All Articles