Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

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

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")
);

 

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.