Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Please see the Cloudera blog for information on the Cloudera Response to CVE-2021-4428

Query versions in phoenix?

Super Guru

I have table which has versions enabled.

CREATE TABLE IF NOT EXISTS customer ( firstName CHAR(15), lastName CHAR(15), address char(100), ssn integer NOT NULL, effective_date DATE NOT NULL CONSTRAINT pk PRIMARY KEY (ssn, effective_date ROW_TIMESTAMP) ) VERSIONS=10000000;

I upserted the record 4 times. How do I query all the versions?

For example I use

select * from customer where EFFECTIVE_DATE < CURRENT_DATE();

I am expecting all the versions for that row. Please advise.

3 REPLIES 3

Phoenix does not (yet) expose multiple row versions. You'd have to use the HBase API directly to get access to other row versions.

You can check relevant discussion on PHOENIX-590 for your requirements.

Currently, Phoenix doesn't support getting all the versions at the same time, but it allows you to do point-in-time queries to see a version at that time. check below link

https://phoenix.apache.org/faq.html#Can_phoenix_work_on_tables_with_arbitrary_timestamp_as_flexible_...

New Contributor

We get startKey, stopKey , PK from phoenix(very important) , then exe a hbase scan (scan.setMaxVersions()) to get all versions data