hbase表上的配置单元表显示整数列为null

a11xaf1n  于 2021-06-02  发布在  Hadoop
关注(0)|答案(1)|浏览(331)

我正在尝试在hbase表上创建配置单元表。详情如下:
hbase表包含如下数据:

Connected to: Phoenix (version 4.7)
Driver: PhoenixEmbeddedDriver (version 4.7)
Autocommit status: true
Transaction isolation: TRANSACTION_READ_COMMITTED
Building list of tables and columns for tab-completion (set fastconnect to true to skip)...
1341/1341 (100%) Done
Done
sqlline version 1.1.8

0: jdbc:phoenix:maxiqtesting1.lti.com:2181:/h> 
select * from HBASE_TEST_6JULY_1792409;

+---------+---------+---------+

| FIELD0  | FIELD1  | FIELD2  |

+---------+---------+---------+

| 1       | qq      | 23      |

| 2       | ee      | 12      |

| 3       | dd      | 123     |

+---------+---------+---------+

3 rows selected (0.139 seconds)
0: jdbc:phoenix:maxiqtesting1.lti.com:2181:/h>

创建配置单元表命令:

CREATE EXTERNAL TABLE HBASE_TEST_6JULY(FIELD0 int,FIELD1 string, FIELD2 int) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,0:FIELD1,0:FIELD2","hbase.table.default.storage.type" = "binary",  'serialization.format'='1')
TBLPROPERTIES("hbase.table.name" = "HBASE_TEST_6JULY_1792409");

配置单元表上的select命令给出如下结果:

hive> select * from HBASE_TEST_6JULY;
OK

-2147483647     qq      -2147483625

-2147483646     ee      -2147483636

-2147483645     dd      -2147483525

Time taken: 0.963 seconds, Fetched: 3 row(s)

整列值显示不正确。如果我在配置单元中将所有列作为字符串,那么在hbase中对应的整数列将为null
有谁能帮助我,通过在hbase上公开配置单元表来提供读取具有正确值的数字/非字符串列的解决方案吗?

xcitsw88

xcitsw881#

要从hbase读取非字符串列,ddl语句应该

CREATE EXTERNAL TABLE HBASE_TEST_6JULY(
FIELD0 int,
FIELD1 string, 
FIELD2 int
) 
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key#b,0:FIELD1,0:FIELD2#b",  'serialization.format'='1')
TBLPROPERTIES("hbase.table.name" = "HBASE_TEST_6JULY_1792409");

注意在int列的列Map限定符中使用了“#b”。这帮我修好了。
请参阅有关此问题的jira问题线程

相关问题