Phoenix map of existing HBase table

I have an Hbase table "http_access_log", now I want to use Apache phoenix for SQL on it.

Should I create a view or phoenix table to map the hbase table? And if the hbase table is updated with the hbase api, will the view or phoenix table be updated?

+4
source share
2 answers

If you have an existing table, you need to create a view to access it:

create view "http_access_log_v" (pk VARCHAR PRIMARY KEY, "colfam1"."colum1" VARCHAR, "colfam1"."colum2" VARCHAR) as select * from "http_access_log";

With the above view, you can make a choice against it as follows:

select * from http_access_log_v;

Example

Say I had a HBase configuration table. I can not make a choice directly against this table through Phoenix.

sqlline> select * from "config"; 
Error: ERROR 1012 (42M03): Table undefined. tableName=config (state=42M03,code=1012)

, select * from "config" HBase:

sqlline> create view "config-data" (pk VARCHAR PRIMARY KEY, "data"."id" VARCHAR, "data"."categoryName" VARCHAR) as select * from "config";
No rows affected (1.588 seconds)

, Phoenix SQL:

sqlline> select * from "config-data";
+------------------------------------------+------------------------------------------+------------------------------------------+
|                    PK                    |                    id                    |               categoryName               |
+------------------------------------------+------------------------------------------+------------------------------------------+
| QA-AA00|D|MC|MSG|C10|M3               | null                                     | null                                     |
| QA-AA00|D|MC|MSG|C2|M1                | null                                     | null                                     |
...

HBase:

sqlline> select * from "config"; Error: ERROR 1012 (42M03): Table undefined. tableName=config (state=42M03,code=1012)

+2

Source: https://habr.com/ru/post/1584418/


All Articles