Created 08-07-2016 03:23 AM
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)
Created 08-08-2016 12:14 AM
Use the ALTER command to add more columns to your table's schema.
Created 08-09-2016 03:21 AM
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
Created 08-09-2016 03:24 AM
Correct. That's why I instructed you to use the ALTER command :)
Created on 06-29-2017 02:52 PM - edited 08-18-2019 04:08 AM
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);
Source: Dynamic Columns in Phoenix