forcedotcom / phoenix

BSD 3-Clause "New" or "Revised" License
558 stars 227 forks source link

Phoenix View on pre-existing HBase namespace table? #746

Open liqw1016 opened 7 years ago

liqw1016 commented 7 years ago

Hey,

When I try to create a Phoenix View on a pre-existing HBase namespace table throws below error:

0: jdbc:phoenix:bigdata01.zk.tuniu.org> CREATE VIEW "wwc_beck"."t1" ("pk" VARCHAR PRIMARY KEY, "f1"."a" VARCHAR, "f1"."b" VARCHAR, "f1"."c" VARCHAR);

Error: ERROR 505 (42000): Table is read only. (state=42000,code=505) org.apache.phoenix.schema.ReadOnlyTableException: ERROR 505 (42000): Table is read only. at org.apache.phoenix.query.ConnectionQueryServicesImpl.ensureTableCreated(ConnectionQueryServicesImpl.java:1034) at org.apache.phoenix.query.ConnectionQueryServicesImpl.createTable(ConnectionQueryServicesImpl.java:1399) at org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:2275) at org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:939) at org.apache.phoenix.compile.CreateTableCompiler$2.execute(CreateTableCompiler.java:211) at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:358) at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:341) at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53) at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:339) at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1511) at sqlline.Commands.execute(Commands.java:822) at sqlline.Commands.sql(Commands.java:732) at sqlline.SqlLine.dispatch(SqlLine.java:813) at sqlline.SqlLine.begin(SqlLine.java:686) at sqlline.SqlLine.start(SqlLine.java:398) at sqlline.SqlLine.main(SqlLine.java:291) 0: jdbc:phoenix:bigdata01.zk.tuniu.org>

Table in HBase like this:

hbase(main):001:0>create 'wwc_beck:t1', {NAME => 'f1', VERSIONS => 5}

hbase(main):002:0>put 'wwc_beck:t1', 'row1', 'f1:a', 'value1' hbase(main):003:0>put 'wwc_beck:t1', 'row2', 'f1:b', 'value2' hbase(main):004:0>put 'wwc_beck:t1', 'row3', 'f1:c', 'value3'

hbase(main):005:0> scan "wwc_beck:t1" ROW COLUMN+CELL
row1 column=f1:a, timestamp=1488101125183, value=value1
row2 column=f1:b, timestamp=1488101125267, value=value2
row3 column=f1:c, timestamp=1488101126005, value=value3
3 row(s) in 0.0230 seconds

liqw.

collinmazb commented 6 years ago

Anyone noticed this problem? Seems we couldn't create view on pre-existing HBase namespace table. We indeed could create on phoenix table, but when the next time you want to change the column type you'll have to drop the column, which leads to data been deleted. This's not acceptable