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.

How to create phoenix view on existing HBase table by splitting primary key to composite keys

Highlighted

How to create phoenix view on existing HBase table by splitting primary key to composite keys

New Contributor

Considering a scenario where rowkey is combination of parts delimited by " | ".

Row Key : part1|part2|part3|1000 column family:f column: "c1" value: "1"

Row Key : part1|part2|part3|1001 column family:f column: "c2" value: "2"

How to create view in phoenix that looks like.

and insert values into Hbase through phoenix

col1col2col3col4c1c2
part1part2part310001null
part1part2part31001null2
1 REPLY 1
Highlighted

Re: How to create phoenix view on existing HBase table by splitting primary key to composite keys

New Contributor

according to this post:https://phoenix.apache.org/faq.html#How_I_map_Phoenix_table_to_an_existing_HBase_table

you can do it like this, say that the existing HBase table is "t1" : 

CREATE VIEW "t1"("col1" varchar not null,
    "col2" varchar not null,
    "col3" varchar not null,
    "col4" integer not null,
    "f"."c1" integer, 
    "f"."c2" integer, 
    CONSTRAINT "ROW" PRIMARY KEY("col1", "col2", "col3", "col4")
);

 

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