创建Hbase表
create 'phoenix_hbase_test','cf1','cf2'
put 'phoenix_hbase_test', 'key1','cf1:name','zhangsan'
put 'phoenix_hbase_test', 'key1','cf2:age','18'
put 'phoenix_hbase_test', 'key2','cf1:name','lisi'
put 'phoenix_hbase_test', 'key2','cf2:age','26'
put 'phoenix_hbase_test', 'key3','cf1:name','chenwu'
put 'phoenix_hbase_test', 'key4','cf2:age','10'
Phoenix 关联
create table "phoenix_hbase_test"("rowkey" varchar primary key, "cf1"."name" varchar , "cf2"."age" varchar)
查询数据发现Phoenix查询不到关联的name,age值
这里使用upsert into 添加一条试试
发现可以查询到,我们去hbase查看一下数据,发现key5 的数据列名为16进制字符?
hbase(main):077:0> scan 'phoenix_hbase_test'
ROW COLUMN+CELL key1 column=cf1:_0, timestamp=1564209151874, value= key1 column=cf1:name, timestamp=1564209151856, value=zhangsan key1 column=cf2:age, timestamp=1564209151874, value=18 key2 column=cf1:_0, timestamp=1564209151907, value= key2 column=cf1:name, timestamp=1564209151891, value=lisi key2 column=cf2:age, timestamp=1564209151907, value=26 key3 column=cf1:_0, timestamp=1564209151922, value= key3 column=cf1:name, timestamp=1564209151922, value=chenwu key4 column=cf1:_0, timestamp=1564209152655, value= key4 column=cf2:age, timestamp=1564209152655, value=10 key5 column=cf1:\x00\x00\x00\x00, timestamp=1564209286035, value=x key5 column=cf1:\x80\x0B, timestamp=1564209286035, value=shazi key5 column=cf2:\x80\x0C, timestamp=1564209286035, value=66
5 row(s) in 0.0180 seconds
查询资料发现,4.10版本只有 Phoenix默认会对字段值进行编码,在创建表中加入column_encoded_bytes=0 即可解决该问题
create table "phoenix_hbase_test"("rowkey" varchar primary key, "cf1"."name" varchar , "cf2"."age" varchar) column_encoded_bytes=0;
官网对该功能的说明:http://phoenix.apache.org/columnencoding.html