<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Views on existing HBase namespace tables in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167688#M130018</link>
    <description>&lt;P&gt;
	Dear Experts, &lt;/P&gt;&lt;P&gt;
	We have HDP 2.5 (Phoenix 4.7.0.2.5.0.0-1245) - does it support View creation on an HBase table created in a namespace using HBase shell (i.e. not created through Phoenix Grammar)?&lt;/P&gt;&lt;P&gt;
	I have run knit,&lt;/P&gt;
&lt;PRE&gt;kinit -k -t /etc/security/keytabs/hbase.headless.keytab hbase-cluster1
&lt;/PRE&gt;&lt;P&gt;
	In Hbase shell,&lt;/P&gt;
&lt;PRE&gt;create 'durham:TEST', 'b'
put 'durham:TEST', '1', 'b:message', 'Hello'
put 'durham:TEST', '2', 'b:message', 'World'
hbase(main):026:0&amp;gt; scan 'durham:TEST'
ROW                         COLUMN+CELL                                                                 
 1                          column=b:message, timestamp=1478511785906, value=Hello                      
 2                          column=b:message, timestamp=1478511794551, value=World 
&lt;/PRE&gt;&lt;P&gt;
	then &lt;STRONG&gt;sqlline&lt;/STRONG&gt;,&lt;/P&gt;
&lt;PRE&gt;0: jdbc:phoenix:localhost:2181/hbase-secure&amp;gt; select DISTINCT TABLE_SCHEM from SYSTEM.CATALOG;
+--------------+
| TABLE_SCHEM  |
+--------------+
| DURHAM       |
| SYSTEM       |
+--------------+
&lt;/PRE&gt;&lt;P&gt;
	create view gives ,&lt;/P&gt;
&lt;PRE&gt;use "durham";
CREATE VIEW "TEST" (
  pk VARCHAR PRIMARY KEY
 ,"b"."message"  VARCHAR
 )
 AS SELECT * FROM "TEST";
&lt;/PRE&gt;&lt;P&gt;
	create view error ,&lt;/P&gt;&lt;PRE&gt;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:1032)
	at org.apache.phoenix.query.ConnectionQueryServicesImpl.createTable(ConnectionQueryServicesImpl.java:1415)
	at org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:2180)
	at org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:865)
	at org.apache.phoenix.compile.CreateTableCompiler$2.execute(CreateTableCompiler.java:194)
	at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:343)
	at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:331)
	at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
	at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:329)
	at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1440)
	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)
&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Nov 2016 17:50:20 GMT</pubDate>
    <dc:creator>christopher_bri</dc:creator>
    <dc:date>2016-11-07T17:50:20Z</dc:date>
    <item>
      <title>Views on existing HBase namespace tables</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167688#M130018</link>
      <description>&lt;P&gt;
	Dear Experts, &lt;/P&gt;&lt;P&gt;
	We have HDP 2.5 (Phoenix 4.7.0.2.5.0.0-1245) - does it support View creation on an HBase table created in a namespace using HBase shell (i.e. not created through Phoenix Grammar)?&lt;/P&gt;&lt;P&gt;
	I have run knit,&lt;/P&gt;
&lt;PRE&gt;kinit -k -t /etc/security/keytabs/hbase.headless.keytab hbase-cluster1
&lt;/PRE&gt;&lt;P&gt;
	In Hbase shell,&lt;/P&gt;
&lt;PRE&gt;create 'durham:TEST', 'b'
put 'durham:TEST', '1', 'b:message', 'Hello'
put 'durham:TEST', '2', 'b:message', 'World'
hbase(main):026:0&amp;gt; scan 'durham:TEST'
ROW                         COLUMN+CELL                                                                 
 1                          column=b:message, timestamp=1478511785906, value=Hello                      
 2                          column=b:message, timestamp=1478511794551, value=World 
&lt;/PRE&gt;&lt;P&gt;
	then &lt;STRONG&gt;sqlline&lt;/STRONG&gt;,&lt;/P&gt;
&lt;PRE&gt;0: jdbc:phoenix:localhost:2181/hbase-secure&amp;gt; select DISTINCT TABLE_SCHEM from SYSTEM.CATALOG;
+--------------+
| TABLE_SCHEM  |
+--------------+
| DURHAM       |
| SYSTEM       |
+--------------+
&lt;/PRE&gt;&lt;P&gt;
	create view gives ,&lt;/P&gt;
&lt;PRE&gt;use "durham";
CREATE VIEW "TEST" (
  pk VARCHAR PRIMARY KEY
 ,"b"."message"  VARCHAR
 )
 AS SELECT * FROM "TEST";
&lt;/PRE&gt;&lt;P&gt;
	create view error ,&lt;/P&gt;&lt;PRE&gt;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:1032)
	at org.apache.phoenix.query.ConnectionQueryServicesImpl.createTable(ConnectionQueryServicesImpl.java:1415)
	at org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:2180)
	at org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:865)
	at org.apache.phoenix.compile.CreateTableCompiler$2.execute(CreateTableCompiler.java:194)
	at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:343)
	at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:331)
	at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
	at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:329)
	at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1440)
	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)
&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Nov 2016 17:50:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167688#M130018</guid>
      <dc:creator>christopher_bri</dc:creator>
      <dc:date>2016-11-07T17:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Views on existing HBase namespace tables</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167689#M130019</link>
      <description>&lt;P&gt;First you can map the table created in HBase to Phoenix with create table query as mentioned in "Mapping to an Existing HBase Table"  at phoenix.apache.org  and then create view on it.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 19:18:07 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167689#M130019</guid>
      <dc:creator>rchintaguntla</dc:creator>
      <dc:date>2016-11-07T19:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Views on existing HBase namespace tables</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167690#M130020</link>
      <description>&lt;P&gt;Rajesh,&lt;/P&gt;&lt;P&gt;Thank you, I didn't see that (it might help if that were in the Views documentation page).&lt;/P&gt;&lt;P&gt;This worked,&lt;/P&gt;&lt;PRE&gt;use "durham";
create table "TEST" (PK VARCHAR PRIMARY KEY, "b"."message" VARCHAR);

SELECT * FROM "TEST";
+-----+----------+
| PK  | message  |
+-----+----------+
| 1   | Hello    |
| 2   | World    |
+-----+----------+
2 rows selected (0.126 seconds)
&lt;/PRE&gt;&lt;P&gt;using this approach (i.e. CREATE TABLE) I actually don't require a View, although it has a different issue:&lt;/P&gt;&lt;PRE&gt;CREATE VIEW "TEST" (  pk VARCHAR PRIMARY KEY ,"b"."message"  VARCHAR ) AS SELECT * FROM "TEST";

Error: ERROR 1036 (42J04): Cannot modify the primary key of a VIEW if last PK column of parent is variable length. columnName=durham.TEST.PK (state=42J04,code=1036)
java.sql.SQLException: ERROR 1036 (42J04): Cannot modify the primary key of a VIEW if last PK column of parent is variable length. columnName=durham.TEST.PK
&lt;/PRE&gt;&lt;P&gt;are VARCHAR PRIMARY KEY's not supported on Views? &lt;/P&gt;&lt;P&gt;Chris.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 19:39:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167690#M130020</guid>
      <dc:creator>christopher_bri</dc:creator>
      <dc:date>2016-11-07T19:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: Views on existing HBase namespace tables</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167691#M130021</link>
      <description>&lt;P&gt;After creating the table you can create view like below&lt;/P&gt;&lt;P&gt;CREATE VIEW "TESTVIEW" AS SELECT * FROM "TEST"&lt;/P&gt;&lt;P&gt;or else if you want to map HBase table as view or read only you can just try without select query.&lt;/P&gt;&lt;PRE&gt;CREATE VIEW "TEST" (  pk VARCHAR PRIMARY KEY ,"b"."message"  VARCHAR ) 
&lt;/PRE&gt;&lt;P&gt;If this solves the problem mark it as best answer.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 19:52:18 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Views-on-existing-HBase-namespace-tables/m-p/167691#M130021</guid>
      <dc:creator>rchintaguntla</dc:creator>
      <dc:date>2016-11-07T19:52:18Z</dc:date>
    </item>
  </channel>
</rss>

