This repository was archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 225
Dynamic Columns
James Taylor edited this page May 16, 2013
·
3 revisions
Sometimes defining a static schema up front is not feasible. Instead, a subset of columns may be specified at table create time while the rest would be specified at query time. As of Phoenix 1.2, specifying columns dynamically is now supported by allowing column definitions to included in parenthesis after the table in the FROM clause on a SELECT statement. Although this is not standard SQL, it is useful to surface this type of functionality to leverage the late binding ability of HBase.
For example:
SELECT eventTime, lastGCTime, usedMemory, maxMemory
FROM EventLog(lastGCTime TIME, usedMemory BIGINT, maxMemory BIGINT)
WHERE eventType = 'OOM' AND lastGCTime < eventTime - 1
Where you may have defined only a subset of your event columns at create time, since each event type may have different properties:
CREATE TABLE EventLog (
eventId BIGINT NOT NULL,
eventTime TIME NOT NULL,
eventType CHAR(3) NOT NULL
CONSTRAINT pk PRIMARY KEY (eventId, eventTime))