phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ciureanu Constantin <ciureanu.constan...@gmail.com>
Subject Re: How to map sparse hbase table with dynamic columns into Phoenix
Date Mon, 12 Dec 2016 09:51:45 GMT
Not sure if this works for the view use-case you have but it's working for
a Phoenix table.

The table create statement should have just the stable columns.

CREATE TABLE IF NOT EXISTS TESTC (
TIMESTAMP BIGINT NOT NULL,
NAME VARCHAR NOT NULL
CONSTRAINT PK PRIMARY KEY (TIMESTAMP, NAME)
);

-- insert whatever dynamic columns you need (there's no limit since one row
is a Map)
UPSERT INTO TESTC(TIMESTAMP,NAME,F1 INTEGER,F2 INTEGER,F3 INTEGER)
VALUES(1,'C',1,2,3);
UPSERT INTO TESTC(TIMESTAMP,NAME, F4 INTEGER,F5 INTEGER,F6 INTEGER)
VALUES(2,'M',4,5,6);

You can read the columns "dynamically" (but you need to know their names
and types in advance to prepare the SELECT :( - again this might be  a
problem in your case).

select TIMESTAMP, NAME, F1, F2, F3, F4, F5, F6 from TESTC(F1 INTEGER,F2
INTEGER,F3 INTEGER,F4 INTEGER,F5 INTEGER,F6 INTEGER);




2016-12-12 7:49 GMT+01:00 Arvind S <arvind18352@gmail.com>:

> Note: as your columns are all in small remember to qualify the table name,
> column family and column names in double quotes "".
> Below example i created should help with the rest ..  i have used capital
> letters for table names and cols to make it easy ;)
> =========================================================
>
> *in hbase *...
>
> create 'TESTER', {NAME=>'F1'}, {NAME=>'F2'}
> put 'TESTER', '1','F1:C1', 'duku'
> put 'TESTER', '1','F1:C2', 'count duku'
> put 'TESTER', '1','F2:COL1', 'yoda'
> put 'TESTER', '1','F2:COL2', 'master yoda'
>
> *in Phoneix* ...
> CREATE TABLE IF NOT EXISTS TESTER (
>       ROW varchar PRIMARY KEY,
>       F1.C1 varchar,
>       F1.C2 varchar,
>       F2.COL1 varchar,
>       F2.COL2 varchar
>       );
> [image: Inline images 2]
>
>
> now to make dynamic column view
> *in hbase *... add new columns
>
> put 'TESTER', '1','F1:C3', 'skywalker'
> put 'TESTER', '1','F2:COL3', 'luke skywalker'
>
> [image: Inline images 3]
>
> *in Phoneix* ... make the dynamic view
>
> CREATE VIEW TESTER_VIEW(
>       F1.C3 varchar,
>       F2.COL3 varchar) AS
> SELECT * FROM TESTER;
>
>
> [image: Inline images 4]
>
>
> On 2016-12-10 05:28 ( 0530), "Sethuramaswamy, Suresh CWR" <
> s...@credit-suisse.com> wrote:
> > All,>
> >
> > We have a sparse hbase table with 3 column families and variable  column
> qualifiers in each row. Can someone help me how to create a phoenix view to
> map this hbase table into phoenix ?>
> >
> > Sample of Hbase table :>
> >
> > Row1:   Key         cf1.name             cf1.id     cf2.age cf3.salary>
> > Row2:   Key         cf1.id     cf1.dept               cf3.salary>
> > Row3:   Key         cf1.client_name               cf1.client_address
>       cf3. Start_date>
> >
> >
> >
> >
> > Suresh Sethuramaswamy>
> > CREDIT SUISSE>
> > Information Technology | Client Intelligence, KFLI 5>
> > One Madison Avenue | 10010 New York | Americas>
> > Phone  1 212 325 1060 <(212)%20325-1060>>
> > suresh.sethuramaswamy@credit-suisse.com<ma...@credit-suisse.com> |
> www.credit-suisse.com<http://www.credit-suisse.com>>
> >
> > ===============================================================================
> >
> > Please access the attached hyperlink for an important electronic
> communications disclaimer: >
> > http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html >
> > ===============================================================================
> >
> >
>

Mime
View raw message