Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Query all dynamic Phoenix columns

Query all dynamic Phoenix columns

Explorer

I have created an hbase table using Phoenix with 3 columns. Then after creating the schema structure and populating with data, I wanted to add one new row with new dynamic columns. After doing so, I want to do a SELECT statement and get all columns including dynamic ones. However this is not working when doing "SELECT * FROM EXAMPLE;" -- any ideas how to do this?

Here is my code:

Table Structure:

CREATE TABLE example (
    my_pk bigint not null,
    m.first_name varchar(50),
    m.last_name varchar(50) 
    CONSTRAINT pk PRIMARY KEY (my_pk))

Table Data:

12345,John,Doe
67890,Mary,Poppins

Inserted dynamic data like so:

UPSERT INTO EXAMPLE (MY_PK, FIRST_NAME, LAST_NAME, lastGCTime TIME, usedMemory BIGINT, maxMemory BIGINT) 
VALUES(1, 'this', 'test', CURRENT_TIME(), 512, 1024)
4 REPLIES 4
Highlighted

Re: Query all dynamic Phoenix columns

Use the ALTER command to add more columns to your table's schema.

http://phoenix.apache.org/language/index.html#alter

Highlighted

Re: Query all dynamic Phoenix columns

Explorer

So i guess you have to modify the schema in order for it to pick up the new columns -- it doesnt update schema automatically on the fly

Highlighted

Re: Query all dynamic Phoenix columns

Correct. That's why I instructed you to use the ALTER command :)

Highlighted

Re: Query all dynamic Phoenix columns

For getting the dynamic columns in your result-set, you need to specify those columns and their schema while querying as well. This feature is available since Phoenix 1.2.

SELECT MY_PK, FIRST_NAME, LAST_NAME, lastGCTime TIME, usedMemory BIGINT, maxMemory BIGINT FROM EXAMPLE(lastGCTime TIME, usedMemory BIGINT, maxMemory BIGINT);

16610-capture.png

Source: Dynamic Columns in Phoenix

Don't have an account?
Coming from Hortonworks? Activate your account here