我想在hbase之上创建配置单元外部表。 Hbase表是通过phoenix创建的。 Phoenix表具有复合主键,而复合主键又在Hbase表中具有复合行键
凤凰创建表
CREATE TABLE Employee (
id Bigint Not Null,
dept varchar(10) Not Null,
Name varchar(25),
pincode Integer,
CONSTRAINT Enployee_PK PRIMARY KEY (id,dept));
upsert语句
upsert into Employee values(1,'DEV','john',1234);
upsert into Employee values(2,'DEV2','john2',2222);
upsert into Employee values(3,'DEV3','john3',3333);
upsert into Employee values(4,'DEV4','john4',4444);
配置单元外部表
CREATE EXTERNAL TABLE hbase_Employee(key struct<id:String,dept:String>,Name String,pincode String) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,0:NAME,0:PINCODE") TBLPROPERTIES ("hbase.table.name" = "EMPLOYEE");
当我从配置单元外部表中选择时,它会给出类似
的输出{"id":"�\u0000\u0000\u0000\u0000\u0000\u0000\u0001DEV","dept":null} john ��
{"id":"�\u0000\u0000\u0000\u0000\u0000\u0000","dept":"DEV2"} john2 �
{"id":"�\u0000\u0000\u0000\u0000\u0000\u0000\u0003DEV3","dept":null} john3 �
{"id":"�\u0000\u0000\u0000\u0000\u0000\u0000\u0004DEV4","dept":null} john4 �\
我不希望字节值需要hbase表中的实际“ id”和“ dept”值。