Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
James Taylor edited this page Jan 30, 2014 · 12 revisions

The standard SQL view syntax (with some limitations) is now supported by Phoenix to enable multiple virtual tables to all share the same underlying physical HBase table. This is especially important in HBase, as you cannot realistically expect to have more than a hundred physical tables and get reasonable performance from HBase.

For example, given the following table definition that defines a base table to collect product metrics:

CREATE  TABLE product_metrics (
    metric_type CHAR(1),
    created_by VARCHAR, 
    created_date DATE, 
    metric_id INTEGER
    CONSTRAINT pk PRIMARY KEY (metric_type, created_by, created_date, metric_id));

You could define the following view:

CREATE VIEW mobile_product_metrics (carrier VARCHAR, dropped_calls BIGINT) AS
SELECT * FROM product_metrics
WHERE metric_type = 'm';

Notice that unlike with standard SQL views, you may define additional columns for your view. The view inherits all of the columns from its base table, in addition to being able to optionally add new KeyValue columns. If your view uses only simple equality expressions in the WHERE clause, you are also allowed to issue DML against the view. For example, in this case you could issue the following UPSERT statement:

Clone this wiki locally