Data and AI Platforms

Using Hive’s HBaseStorageHandler with Existing HBase Tables

By
Hive’s HBaseStorageHandler lets you expose HBase tables as Hive tables so you can run SELECT and INSERT statements over HBase data. This article shows how to configure Hive to talk to HBase, create a new HBase table through Hive and attach Hive EXTERNAL TABLE definitions to existing HBase tables using the correct column family mappings. Because Impala shares the Hive Metastore, it also walks through a full example with US census ZIP code income data: create the HBase table, map it in Hive, bulk load the CSV with Pig and query it from Impala. It reflects a Hive 0.9 / HBase 0.92 and early Impala era setup and is mainly useful for legacy clusters and migrations.

Note (2025): This guide describes the original HBase integration introduced around HIVE-705 for Hive 0.9 and HBase 0.92. Modern Hadoop stacks often favour storing analytics data in Parquet or Iceberg and querying it via engines like Hive, Impala, Trino or Spark. Use this pattern primarily when you need to understand or maintain existing Hive-on-HBase tables, not for new designs.

Hive-HBase integration in a nutshell

Hive can read from and write to HBase tables using a dedicated storage handler. Once configured, you can:

  • Run SELECT queries over HBase-backed tables.
  • Use INSERT to write data into HBase via Hive.
  • Expose existing HBase tables to Hive using CREATE EXTERNAL TABLE.

The feature is implemented by HBaseStorageHandler and was introduced in HIVE-705. At the time of writing, Hive 0.9 required HBase 0.92 or newer for this integration to work.

Prerequisites and storage handler

The HBase storage handler ships with Hive and should be available in the Hive library directory:

$HIVE_HOME/lib/hive-hbase-handler*.jar

In that era, the handler required:

  • Hadoop 0.20.x or later
  • Zookeeper 3.3.4 or later
  • Matching HBase and Hive versions (e.g. HBase 0.92 with Hive 0.9)

Configuring Hive to see HBase

Hive needs to know where to find the HBase configuration so that it can locate Zookeeper, the HBase master and region servers. One simple way is to set the HBase ZooKeeper quorum in hive-site.xml:

<property>
  <name>hbase.zookeeper.quorum</name>
  <value>zk1.example.com,zk2.example.com,zk3.example.com</value>
</property>

Alternatively, put /etc/hbase/conf on Hive's classpath (for example via HADOOP_CLASSPATH) so Hive reads hbase-site.xml directly. Note that hive.aux.jars.path (or hive --auxpath) is for jars, such as the handler, HBase and ZooKeeper jars, not for configuration directories.

After editing hive-site.xml, distribute:

  • hbase-site.xml
  • hive-site.xml

to all Hive clients and nodes that will run HiveServer or Hive CLI. This ensures that all Hive components resolve the same HBase/Zookeeper configuration.

Create a new HBase table from Hive

You can define a Hive table that is backed by a new HBase table using HBaseStorageHandler and the hbase.columns.mapping property. For example:

CREATE TABLE hbase_test (
  key1 STRING,
  col1 STRING
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
  "hbase.columns.mapping" = ":key,cf1:c1"
)
TBLPROPERTIES (
  "hbase.table.name" = "hive_test"
);

This statement tells Hive to:

  • Create an HBase table named hive_test if it does not exist.
  • Map:
    • key1 to the HBase row key (denoted by :key).
    • col1 to column c1 in column family cf1.

In HBase shell, the table then looks like:

hbase(main):001:0> describe 'hive_test'
DESCRIPTION                                                                 ENABLED
{NAME => 'hive_test',
 FAMILIES => [{NAME => 'cf1', BLOOMFILTER => 'NONE',
 REPLICATION_SCOPE => '0', VERSIONS => '3', COMPRESSION => 'NONE',
 MIN_VERSIONS => '0', TTL => '2147483647', BLOCKSIZE => '65536',
 IN_MEMORY => 'false', BLOCKCACHE => 'true'}]}                             true
1 row(s) in 0.1190 seconds

From here, you can run Hive queries like SELECT key1, col1 FROM hbase_test and Hive will read directly from HBase.

Attaching Hive to an existing HBase table

More often, you already have data in HBase and want to query it from Hive. In that case, you use CREATE EXTERNAL TABLE so Hive does not own the HBase table lifecycle.

Inspect the HBase schema first

Start by inspecting the HBase table to find its column families and qualifiers:

hbase(main):003:0> describe 't1'
DESCRIPTION                                                                 ENABLED
{NAME => 't1',
 FAMILIES => [{NAME => 'f1', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0',
 COMPRESSION => 'NONE', VERSIONS => '1', TTL => '2147483647',
 MIN_VERSIONS => '0', BLOCKSIZE => '65536', IN_MEMORY => 'false',
 BLOCKCACHE => 'true'}]}                                                    true
1 row(s) in 0.0700 seconds

In this example, the table t1 has a single column family f1. We’ll map a Hive column to one of its qualifiers, for example f1:c1.

Create an EXTERNAL table in Hive

Hive does not support ALTER for non-native (HBase-backed) tables in this old integration. Instead, you define an EXTERNAL table from the start:

CREATE EXTERNAL TABLE hbase_test2 (
  key1 STRING,
  col1 STRING
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
  "hbase.columns.mapping" = ":key,f1:c1"
)
TBLPROPERTIES (
  "hbase.table.name" = "t1"
);

Here we:

  • Map key1 to the HBase row key (:key).
  • Map col1 to column c1 in family f1.
  • Tell Hive the underlying HBase table is t1 via hbase.table.name.

From Hive’s perspective, the table looks like a regular two-column table:

hive> describe hbase_test2;
OK
key1    string  from deserializer
col1    string  from deserializer
Time taken: 0.106 seconds

You can now run SELECT queries on hbase_test2, and Hive will read from the existing HBase table t1. Depending on your setup, INSERT operations can also write into HBase through this mapping.

Querying the same HBase tables from Impala

Impala uses the Hive Metastore to find tables and their storage. So once you have mapped an HBase table in Hive with HBaseStorageHandler, Impala can see it too:

  • HBase table → mapped as a Hive external table via HBaseStorageHandler
  • Hive external table → visible to Impala via the shared Hive Metastore
  • Impala → runs SQL against the HBase data, as long as the mapping is correct

Here is a full example with public US census data (around 2000) that has ZIP codes and income values. The scripts are in my GitHub repository.

The sample data

cat DEC_00_SF3_P077_with_ann_noheader.csv

8600000US00601,00601,006015-DigitZCTA,0063-DigitZCTA,11102
8600000US00602,00602,006025-DigitZCTA,0063-DigitZCTA,12869
8600000US00603,00603,006035-DigitZCTA,0063-DigitZCTA,12423
8600000US00604,00604,006045-DigitZCTA,0063-DigitZCTA,33548
8600000US00606,00606,006065-DigitZCTA,0063-DigitZCTA,10603

Each row has an id (used as the HBase row key), the ZIP code, two description fields and the income value.

Step 1. Create the HBase table

create 'zipcode_hive', 'id', 'zip', 'desc', 'income'

The row key is the census id (for example 8600000US00601). ZIP, descriptions and income live in separate column families.

Step 2. Map it as a Hive external table

CREATE EXTERNAL TABLE ZIPCODE_HBASE (
  key   STRING,
  zip   STRING,
  desc1 STRING,
  desc2 STRING,
  income STRING
)
ROW FORMAT DELIMITED
  FIELDS TERMINATED BY ','
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
  "hbase.columns.mapping" = ":key,zip:zip,desc:desc1,desc:desc2,income:income"
)
TBLPROPERTIES (
  "hbase.table.name" = "zipcode_hive"
);
  • :key → HBase row key
  • zip:zip → column zip in family zip
  • desc:desc1, desc:desc2 → two columns in the desc family
  • income:income → column income in family income

Step 3. Load the CSV into HBase with Pig

Copy the CSV into HDFS and let Pig write it into HBase. A Hive staging table works too, but Pig keeps it short:

cat PopulateData.pig

copyFromLocal DEC_00_SF3_P077_with_ann_noheader.csv ziptest.csv

A = LOAD 'ziptest.csv'
    USING PigStorage(',')
    AS (id:chararray,
        zip:chararray,
        desc1:chararray,
        desc2:chararray,
        income:chararray);

STORE A INTO 'hbase://zipcode_hive'
  USING org.apache.pig.backend.hadoop.hbase.HBaseStorage(
    'zip:zip,desc:desc1,desc:desc2,income:income'
  );

A quick check in the HBase shell:

scan 'zipcode_hive', LIMIT => 2

ROW                         COLUMN+CELL
8600000US00601             column=desc:desc1,   timestamp=..., value=006015-DigitZCTA
8600000US00601             column=desc:desc2,   timestamp=..., value=0063-DigitZCTA
8600000US00601             column=income:income,timestamp=..., value=11102
8600000US00601             column=zip:zip,      timestamp=..., value=00601

8600000US00602             column=desc:desc1,   timestamp=..., value=006025-DigitZCTA
8600000US00602             column=desc:desc2,   timestamp=..., value=0063-DigitZCTA
8600000US00602             column=income:income,timestamp=..., value=12869
8600000US00602             column=zip:zip,      timestamp=..., value=00602

Step 4. Query from Impala

After INVALIDATE METADATA, the table shows up in Impala:

-- connect to your Impala daemon
Using service name 'impala' for kerberos
Connected to hadoop1:21000
Server version: impalad version 1.0 RELEASE (build d1bf0d1dac339af3692ffa17a5e3fdae0aed751f)

INVALIDATE METADATA ZIPCODE_HBASE;

-- basic sanity query
SELECT * FROM ZIPCODE_HBASE LIMIT 4;

+----------------+------------------+----------------+--------+-------+
| key            | desc1            | desc2          | income | zip   |
+----------------+------------------+----------------+--------+-------+
| 8600000US00601 | 006015-DigitZCTA | 0063-DigitZCTA | 11102  | 00601 |
| 8600000US00602 | 006025-DigitZCTA | 0063-DigitZCTA | 12869  | 00602 |
| 8600000US00603 | 006035-DigitZCTA | 0063-DigitZCTA | 12423  | 00603 |
| 8600000US00604 | 006045-DigitZCTA | 0063-DigitZCTA | 33548  | 00604 |
+----------------+------------------+----------------+--------+-------+
Returned 4 row(s) in 0.42s

Now you can run normal SQL against data that lives in HBase:

SELECT *
FROM ZIPCODE_HBASE
WHERE income BETWEEN '1000' AND '5000'
ORDER BY income DESC
LIMIT 20;
+----------------+------------------+----------------+--------+-------+
| key            | desc1            | desc2          | income | zip   |
+----------------+------------------+----------------+--------+-------+
| 8600000US64138 | 641385-DigitZCTA | 6413-DigitZCTA | 49995  | 64138 |
| 8600000US12477 | 124775-DigitZCTA | 1243-DigitZCTA | 49993  | 12477 |
| 8600000US33025 | 330255-DigitZCTA | 3303-DigitZCTA | 49991  | 33025 |
| 8600000US44119 | 441195-DigitZCTA | 4413-DigitZCTA | 49988  | 44119 |
| 8600000US34997 | 349975-DigitZCTA | 3493-DigitZCTA | 49982  | 34997 |
| 8600000US70665 | 706655-DigitZCTA | 7063-DigitZCTA | 49981  | 70665 |
| 8600000US28625 | 286255-DigitZCTA | 2863-DigitZCTA | 49981  | 28625 |
| 8600000US76134 | 761345-DigitZCTA | 7613-DigitZCTA | 49979  | 76134 |
| 8600000US44618 | 446185-DigitZCTA | 4463-DigitZCTA | 49978  | 44618 |
| 8600000US65714 | 657145-DigitZCTA | 6573-DigitZCTA | 49978  | 65714 |
| 8600000US77338 | 773385-DigitZCTA | 7733-DigitZCTA | 49976  | 77338 |
| 8600000US14622 | 146225-DigitZCTA | 1463-DigitZCTA | 49972  | 14622 |
| 8600000US84339 | 843395-DigitZCTA | 8433-DigitZCTA | 49972  | 84339 |
| 8600000US85020 | 850205-DigitZCTA | 8503-DigitZCTA | 49967  | 85020 |
| 8600000US64061 | 640615-DigitZCTA | 6403-DigitZCTA | 49964  | 64061 |
| 8600000US97361 | 973615-DigitZCTA | 9733-DigitZCTA | 49961  | 97361 |
| 8600000US30008 | 300085-DigitZCTA | 3003-DigitZCTA | 49960  | 30008 |
| 8600000US48634 | 486345-DigitZCTA | 4863-DigitZCTA | 49958  | 48634 |
| 8600000US47923 | 479235-DigitZCTA | 4793-DigitZCTA | 49946  | 47923 |
| 8600000US46958 | 469585-DigitZCTA | 4693-DigitZCTA | 49946  | 46958 |
+----------------+------------------+----------------+--------+-------+
Returned 20 row(s) in 1.08s

Note that income is a STRING here, so the BETWEEN filter compares text, not numbers. That is why values like 49995 come back. Map numeric columns with the right type if you need numeric filters. The point is the pattern: once the Hive to HBase mapping is in place, Impala reads HBase at query time like a regular table.

This setup still helps when you keep a legacy CDH cluster with HBase-backed tables online, or when you migrate old Impala-on-HBase workloads step by step. For new work, land the data as Parquet or Iceberg and keep HBase for operational access paths only.

Things to keep in mind

  • This integration is tied to specific Hive/HBase versions (Hive 0.9 with HBase 0.92 in this example).
  • Schema evolution is limited: non-native tables cannot be freely altered.
  • Performance depends heavily on HBase table design (row key, regions, compression and block cache).
  • For new workloads, prefer modern storage formats (Parquet/Iceberg) and engines that optimize for analytical queries.

If you still run legacy Hive-on-HBase tables, this pattern provides a clear way to expose them to SQL without rewriting your storage layer immediately. It also helps when planning a migration by making HBase data visible in SQL for validation and export.

Need help with distributed systems, backend engineering or data platforms? See my consulting services.

Alexander Alten

Alexander Alten

Founder of Scalytics, co-creator and PMC member of Apache Wayang, and author of KafScale. I write about Kafka, streaming, data platforms, IoT and AI agent infrastructure in production.