phoenix创建表在hbase中无法正常显示列名,会对hbase列进行编码存储

phoenix创建表

0: jdbc:phoenix:hadoop01:2181:/hbase> create table "phoenix_02"(id varchar primary key,"cf"."name" varchar,"cf"."age" varchar);
No rows affected (2.881 seconds)
0: jdbc:phoenix:hadoop01:2181:/hbase> !tables
+------------+--------------+----------------+---------------+----------+------------+-----------+
| TABLE_CAT  | TABLE_SCHEM  |   TABLE_NAME   |  TABLE_TYPE   | REMARKS  | TYPE_NAME  | SELF_REFE |
+------------+--------------+----------------+---------------+----------+------------+-----------+
|            | SYSTEM       | CATALOG        | SYSTEM TABLE  |          |            |           |
|            | SYSTEM       | FUNCTION       | SYSTEM TABLE  |          |            |           |
|            | SYSTEM       | LOG            | SYSTEM TABLE  |          |            |           |
|            | SYSTEM       | SEQUENCE       | SYSTEM TABLE  |          |            |           |
|            | SYSTEM       | STATS          | SYSTEM TABLE  |          |            |           |          |        |
|            |              | phoenix_02     | TABLE         |          |            |           |
+------------+--------------+----------------+---------------+----------+------------+-----------+
0: jdbc:phoenix:hadoop01:2181:/hbase> upsert into "phoenix_02" values('1','zs','20')
. . . . . . . . . . . . . . . . . . > ;
1 row affected (0.181 seconds)
0: jdbc:phoenix:hadoop01:2181:/hbase> select * from "phoenix_02"
. . . . . . . . . . . . . . . . . . > ;
+-----+-------+------+
| ID  | name  | age  |
+-----+-------+------+
| 1   | zs    | 20   |
+-----+-------+------+
1 row selected (0.115 seconds)

hbase shell中scan结果

hbase(main):003:0> scan "phoenix_02"
ROW                       COLUMN+CELL                                                             
 1                        column=cf:\x00\x00\x00\x00, timestamp=1562968809310, value=x            
 1                        column=cf:\x80\x0B, timestamp=1562968809310, value=zs                   
 1                        column=cf:\x80\x0C, timestamp=1562968809310, value=20                   
1 row(s) in 0.2880 seconds

结果显示编码显示,尝试多种方法,最后找到了适合自己的一种

0: jdbc:phoenix:hadoop01:2181:/hbase> create table "phoenix_02"
. . . . . . . . . . . . . . . . . . > (id varchar primary key,
. . . . . . . . . . . . . . . . . . > "info"."name" varchar,"info"."age" varchar)
. . . . . . . . . . . . . . . . . . > COLUMN_ENCODED_BYTES= 0;
No rows affected (2.424 seconds)
0: jdbc:phoenix:hadoop01:2181:/hbase> !tables
+------------+--------------+----------------+---------------+----------+------------+-----------+
| TABLE_CAT  | TABLE_SCHEM  |   TABLE_NAME   |  TABLE_TYPE   | REMARKS  | TYPE_NAME  | SELF_REFE |
+------------+--------------+----------------+---------------+----------+------------+-----------+
|            | SYSTEM       | CATALOG        | SYSTEM TABLE  |          |            |           |
|            | SYSTEM       | FUNCTION       | SYSTEM TABLE  |          |            |           |
|            | SYSTEM       | LOG            | SYSTEM TABLE  |          |            |           |
|            | SYSTEM       | SEQUENCE       | SYSTEM TABLE  |          |            |           |
|            | SYSTEM       | STATS          | SYSTEM TABLE  |          |            |            |          |
|            |              | phoenix_02     | TABLE         |          |            |           |
+------------+--------------+----------------+---------------+----------+------------+-----------+
0: jdbc:phoenix:hadoop01:2181:/hbase> upsert into "phoenix_02" values('1','zs','30')
. . . . . . . . . . . . . . . . . . > ;
1 row affected (0.154 seconds)
0: jdbc:phoenix:hadoop01:2181:/hbase> select * from "phoenix_02";
+-----+-------+------+
| ID  | name  | age  |
+-----+-------+------+
| 1   | zs    | 30   |
+-----+-------+------+
1 row selected (0.206 seconds)

hbase shell中scan结果

hbase(main):006:0> scan "phoenix_02"
ROW                       COLUMN+CELL                                                             
 1                        column=info:_0, timestamp=1562969115795, value=x                        
 1                        column=info:age, timestamp=1562969115795, value=30                      
 1                        column=info:name, timestamp=1562969115795, value=zs                     
1 row(s) in 0.2150 seconds

需要在phoenix中创建表的时候最后加上
COLUMN_ENCODED_BYTES= 0
或者
COLUMN_ENCODED_BYTES=‘NONE’
即可

你可能感兴趣的:(问题,phoenix,hbase,phoenix,hbase)