简体   繁体   中英

phoenix error: hbase table undefined, even though it is present

I am trying to access my hbase running on my local machine with zookeeper at localhost:2181. I installed phoenix-3.3.1-bin and trying to access an already existing hbase tabe, but could not. So, simply to test, i created a table using phoenix commandline and see it when i run !tables command. but when i run selet command, it shows error.

This is what I am doing and i am using mac, hbase-0.94.26. Same thing is happening with squirrel-sql client also.

0: jdbc:phoenix:localhost> CREATE TABLE stats.prod_metrics ( host char(50) not null, created_date date not null,
. . . . . . . . . . . . .>     txn_count bigint CONSTRAINT pk PRIMARY KEY (host, created_date) );
No rows affected (1.82 seconds)

0: jdbc:phoenix:localhost> !tables
+------------------------------------------+------------------------------------------+------------------------------------------+---------------------------+
|                TABLE_CAT                 |               TABLE_SCHEM                |                TABLE_NAME                |                TABLE_TYPE |
+------------------------------------------+------------------------------------------+------------------------------------------+---------------------------+
|                                          | SYSTEM                                   | CATALOG                                  | SYSTEM TABLE              |
|                                          | SYSTEM                                   | SEQUENCE                                 | SYSTEM TABLE              |
|                                          | SYSTEM                                   | STATS                                    | SYSTEM TABLE              |
|                                          | STATS                                    | PROD_METRICS                             | TABLE                     |
+------------------------------------------+------------------------------------------+------------------------------------------+---------------------------+

0: jdbc:phoenix:localhost> select * from PROD_METRICS;
    Error: ERROR 1012 (42M03): Table undefined. tableName=PROD_METRICS (state=42M03,code=1012)
    org.apache.phoenix.schema.TableNotFoundException: ERROR 1012 (42M03): Table undefined. tableName=PROD_METRICS
        at org.apache.phoenix.compile.FromCompiler$BaseColumnResolver.createTableRef(FromCompiler.java:336)
        at org.apache.phoenix.compile.FromCompiler$SingleTableColumnResolver.<init>(FromCompiler.java:236)
        at org.apache.phoenix.compile.FromCompiler.getResolverForQuery(FromCompiler.java:159)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:318)
        at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:308)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:225)
        at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:221)
        at org.apache.phoenix.util.PhoenixContextExecutor.call(PhoenixContextExecutor.java:54)
        at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:221)
        at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1059)
        at sqlline.Commands.execute(Commands.java:822)
        at sqlline.Commands.sql(Commands.java:732)
        at sqlline.SqlLine.dispatch(SqlLine.java:808)
        at sqlline.SqlLine.begin(SqlLine.java:681)
        at sqlline.SqlLine.start(SqlLine.java:398)
        at sqlline.SqlLine.main(SqlLine.java:292)

If you created the table in HBase using lowercase letters, you need to enclose the table name in quotations. Otherwise, Phoenix will convert the table name to uppercase and it will not find your table.

Phoenix tables (and views) are specially "decorated" hbase tables. Ie they have coprocessors attached and some extra chunk of meta data, plus they are registered in the Phoenix system catalog, while plain hbase tables are not. So all Phoenix tables are hbase tables, but hbase tables are not necessarily Phoenix tables.

I was also facing the same issue. It was due to different version of phoneix-client.jar then the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM