Hive associated with HBase table

Source: Internet
Author: User

For more information about HBase and Hive Association tables:


There are 2 forms of hive creation associated HBase tables:

The first type:
Hive> CREATE TABLE hive (ID string,name string, age int)
> Stored by ' org.apache.hadoop.hive.hbase.HBaseStorageHandler '
> With Serdeproperties ("hbase.columns.mapping" = ": Key,cf:name,cf:age")
> tblproperties ("hbase.table.name" = "hbase");

This is the case that HBase did not have this table. The HBase table is created when the hive builds the table. In this case, the Hive table directory for HDFs has a hive folder, but there is no data (data exists in hbase).

hive> Insert Overwrite table hive
> select * from Test;
When hive uses the Overwrite keyword to insert data. The original data will not be deleted, and the same line health will be overwritten by the update. Because the data is in HBase, follow the rules for HBase to insert data.

When hive deletes a hive table, the HBase table is also deleted.
yourselves delete hbase, disabled table first, then drop table
The HBase table is deleted, and the zookeeper inside is deleted.
But hive is still inside, with show tables can also find out. There is also information about the hive table in TBLs in MySQL. But when you query with SELECT * from Hive, the table does not exist (tablenotfoundexception)
Then delete the table in hive will be error tablenotfoundexception). When you continue to show tables, you find that the table is gone. There are no hive tables in the TBLs.


The second type: external
Hive> Create external Table hive (ID string,name string, CT string)
> Stored by ' org.apache.hadoop.hive.hbase.HBaseStorageHandler '
> With Serdeproperties ("hbase.columns.mapping" = ": Key,cf:name,cf:ct")
> tblproperties ("hbase.table.name" = "hbase");

This is the case that HBase already has this table, creating a hive table to manage the HBase table.

hive> Insert Overwrite table hive
> select * from Test;
When hive uses the Overwrite keyword to insert data. Same as in the first case.

Deleting a hive table has no effect on hbase
But first remove the HBase table hive will report tablenotfoundexception
But removing hive does not report the error above.

Hive associated with HBase table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.