<?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 When creating a Phoenix view over an existing Hbase table, is it possible to map values to anything other than &amp;quot;VARCHAR&amp;quot; in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/When-creating-a-Phoenix-view-over-an-existing-Hbase-table-is/m-p/175630#M67598</link>
    <description>&lt;P&gt;	Hi,&lt;/P&gt;&lt;P&gt;I've got the following existing table created in HBASE :&lt;/P&gt;&lt;PRE&gt;#Hbase table definition 
create 'WEB_STAT_INFO', 'info', 'usage'

#Populate HBase table 
put 'WEB_STAT_INFO', 'row1', 'info:host', 'Host A'
put 'WEB_STAT_INFO', 'row1', 'info:domain', 'Domain A'
put 'WEB_STAT_INFO', 'row1', 'usage:core', '15'

#view hbase data 
scan 'WEB_STAT_INFO'&lt;/PRE&gt;&lt;P&gt;I would like to create a Phoenix view on top of it. &lt;/P&gt;&lt;P&gt;Mapping all data to VARCHAR works fine &lt;/P&gt;&lt;PRE&gt;0: jdbc:phoenix:localhost:2181/hbase&amp;gt; CREATE VIEW "WEB_STAT_INFO" ( ROWKEY VARCHAR PRIMARY KEY, "info"."host" VARCHAR, "info"."domain" VARCHAR, "usage"."core" VARCHAR ) ;
No rows affected (0.069 seconds)

0: jdbc:phoenix:localhost:2181/hbase&amp;gt; select * from WEB_STAT_INFO ;
+---------+---------+-----------+-------+
| ROWKEY  |  host   |  domain   | core  |
+---------+---------+-----------+-------+
| row1    | Host A  | Domain A  | 15    |
+---------+---------+-----------+-------+
1 row selected (0.081 seconds)
&lt;/PRE&gt;&lt;P&gt;Mapping to anything else results in an error... &lt;/P&gt;&lt;P&gt;ex : &lt;/P&gt;&lt;PRE&gt;0: jdbc:phoenix:localhost:2181/hbase&amp;gt; CREATE VIEW "WEB_STAT_INFO" ( ROWKEY VARCHAR PRIMARY KEY, "info"."host" VARCHAR, "info"."domain" VARCHAR, "usage"."core" INTEGER ) ;
No rows affected (0.064 seconds)
0: jdbc:phoenix:localhost:2181/hbase&amp;gt; select * from WEB_STAT_INFO ;
Error: ERROR 201 (22000): Illegal data. Expected length of at least 4 bytes, but had 2 (state=22000,code=201)
java.sql.SQLException: ERROR 201 (22000): Illegal data. Expected length of at least 4 bytes, but had 2
at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:442)
at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:145)
at org.apache.phoenix.schema.KeyValueSchema.next(KeyValueSchema.java:211)
at org.apache.phoenix.expression.ProjectedColumnExpression.evaluate(ProjectedColumnExpression.java:115)
at org.apache.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:69)
at org.apache.phoenix.jdbc.PhoenixResultSet.getObject(PhoenixResultSet.java:524)
at sqlline.Rows$Row.&amp;lt;init&amp;gt;(Rows.java:157)
at sqlline.BufferedRows.&amp;lt;init&amp;gt;(BufferedRows.java:38)
at sqlline.SqlLine.print(SqlLine.java:1650)
at sqlline.Commands.execute(Commands.java:833)
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;&lt;P&gt;Examples based on HDP 2.6.1 &lt;/P&gt;&lt;P&gt;Note :  I know that best practices recommend to create tables directly through Phoenix but in this particular use case the HBase table is used by an existing application. &lt;BR /&gt;The objective is to facilitate data access without having any rewrites to the existing application&lt;/P&gt;</description>
    <pubDate>Mon, 04 Sep 2017 20:36:06 GMT</pubDate>
    <dc:creator>mlamairesse</dc:creator>
    <dc:date>2017-09-04T20:36:06Z</dc:date>
    <item>
      <title>When creating a Phoenix view over an existing Hbase table, is it possible to map values to anything other than "VARCHAR"</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/When-creating-a-Phoenix-view-over-an-existing-Hbase-table-is/m-p/175630#M67598</link>
      <description>&lt;P&gt;	Hi,&lt;/P&gt;&lt;P&gt;I've got the following existing table created in HBASE :&lt;/P&gt;&lt;PRE&gt;#Hbase table definition 
create 'WEB_STAT_INFO', 'info', 'usage'

#Populate HBase table 
put 'WEB_STAT_INFO', 'row1', 'info:host', 'Host A'
put 'WEB_STAT_INFO', 'row1', 'info:domain', 'Domain A'
put 'WEB_STAT_INFO', 'row1', 'usage:core', '15'

#view hbase data 
scan 'WEB_STAT_INFO'&lt;/PRE&gt;&lt;P&gt;I would like to create a Phoenix view on top of it. &lt;/P&gt;&lt;P&gt;Mapping all data to VARCHAR works fine &lt;/P&gt;&lt;PRE&gt;0: jdbc:phoenix:localhost:2181/hbase&amp;gt; CREATE VIEW "WEB_STAT_INFO" ( ROWKEY VARCHAR PRIMARY KEY, "info"."host" VARCHAR, "info"."domain" VARCHAR, "usage"."core" VARCHAR ) ;
No rows affected (0.069 seconds)

0: jdbc:phoenix:localhost:2181/hbase&amp;gt; select * from WEB_STAT_INFO ;
+---------+---------+-----------+-------+
| ROWKEY  |  host   |  domain   | core  |
+---------+---------+-----------+-------+
| row1    | Host A  | Domain A  | 15    |
+---------+---------+-----------+-------+
1 row selected (0.081 seconds)
&lt;/PRE&gt;&lt;P&gt;Mapping to anything else results in an error... &lt;/P&gt;&lt;P&gt;ex : &lt;/P&gt;&lt;PRE&gt;0: jdbc:phoenix:localhost:2181/hbase&amp;gt; CREATE VIEW "WEB_STAT_INFO" ( ROWKEY VARCHAR PRIMARY KEY, "info"."host" VARCHAR, "info"."domain" VARCHAR, "usage"."core" INTEGER ) ;
No rows affected (0.064 seconds)
0: jdbc:phoenix:localhost:2181/hbase&amp;gt; select * from WEB_STAT_INFO ;
Error: ERROR 201 (22000): Illegal data. Expected length of at least 4 bytes, but had 2 (state=22000,code=201)
java.sql.SQLException: ERROR 201 (22000): Illegal data. Expected length of at least 4 bytes, but had 2
at org.apache.phoenix.exception.SQLExceptionCode$Factory$1.newException(SQLExceptionCode.java:442)
at org.apache.phoenix.exception.SQLExceptionInfo.buildException(SQLExceptionInfo.java:145)
at org.apache.phoenix.schema.KeyValueSchema.next(KeyValueSchema.java:211)
at org.apache.phoenix.expression.ProjectedColumnExpression.evaluate(ProjectedColumnExpression.java:115)
at org.apache.phoenix.compile.ExpressionProjector.getValue(ExpressionProjector.java:69)
at org.apache.phoenix.jdbc.PhoenixResultSet.getObject(PhoenixResultSet.java:524)
at sqlline.Rows$Row.&amp;lt;init&amp;gt;(Rows.java:157)
at sqlline.BufferedRows.&amp;lt;init&amp;gt;(BufferedRows.java:38)
at sqlline.SqlLine.print(SqlLine.java:1650)
at sqlline.Commands.execute(Commands.java:833)
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;&lt;P&gt;Examples based on HDP 2.6.1 &lt;/P&gt;&lt;P&gt;Note :  I know that best practices recommend to create tables directly through Phoenix but in this particular use case the HBase table is used by an existing application. &lt;BR /&gt;The objective is to facilitate data access without having any rewrites to the existing application&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2017 20:36:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/When-creating-a-Phoenix-view-over-an-existing-Hbase-table-is/m-p/175630#M67598</guid>
      <dc:creator>mlamairesse</dc:creator>
      <dc:date>2017-09-04T20:36:06Z</dc:date>
    </item>
    <item>
      <title>Re: When creating a Phoenix view over an existing Hbase table, is it possible to map values to anything other than "VARCHAR"</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/When-creating-a-Phoenix-view-over-an-existing-Hbase-table-is/m-p/175631#M67599</link>
      <description>&lt;P&gt;Unless you have explicitly written the data the first time in the byte-representation which Phoenix requires, you cannot treat the data as any other type than VARCHAR. This is not simply a "best practice" -- this fundamentally does not work when you write the data in a different representation than Phoenix expects.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 21:45:33 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/When-creating-a-Phoenix-view-over-an-existing-Hbase-table-is/m-p/175631#M67599</guid>
      <dc:creator>elserj</dc:creator>
      <dc:date>2017-09-05T21:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: When creating a Phoenix view over an existing Hbase table, is it possible to map values to anything other than "VARCHAR"</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/When-creating-a-Phoenix-view-over-an-existing-Hbase-table-is/m-p/175632#M67600</link>
      <description>&lt;P&gt;It's better you declare every field as VARCHAR and then use functions to convert them to numbers[1] for mathematical operations.&lt;/P&gt;&lt;P&gt;[1] &lt;A href="https://phoenix.apache.org/language/functions.html#to_number" target="_blank"&gt;https://phoenix.apache.org/language/functions.html#to_number&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Sep 2017 16:58:16 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/When-creating-a-Phoenix-view-over-an-existing-Hbase-table-is/m-p/175632#M67600</guid>
      <dc:creator>asinghal</dc:creator>
      <dc:date>2017-09-07T16:58:16Z</dc:date>
    </item>
  </channel>
</rss>

