【问题标题】:Hive query from external hbase table directly do not get the same row count from hive table created from the external table直接来自外部 hbase 表的 Hive 查询不会从外部表创建的 Hive 表中获取相同的行数
【发布时间】:2018-10-17 15:55:03
【问题描述】:

我创建了一个链接到 hbase 表的 hive 外部表,例如:

create external table user_test_external
(
 id   string,
 name string,
 age  string,
 createtime string
) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES("hbase.columns.mapping" = ":key,info:name,info:age,info:createtime") TBLPROPERTIES("hbase.table.name" = "test_hbase");

然后我从外部表 user_test_external 查询在 '2018-10-17' 上创建的所有用户,例如:

select count(*) from user_test_external where createtime = '2018-10-17'

假设,我得到了row count = A

现在,我从外部表 user_test_external 创建一个配置单元表,

CREATE TABLE user_test AS 
SELECT * 
FROM user_test_external 
WHERE createtime = '2018-10-17'

然后,我使用表user_test 计数

SELECT COUNT(*)  AS row_cnt
FROM  user_test 
WHERE createtime = '2018-10-17'

我得到了row_cnt = B,而 A != B,当我使用 desc formatted table user_test 时,它会显示行数 = A。我对这个连线结果感到非常困惑。真的很感激如果有人可以提供帮助。

【问题讨论】:

    标签: hive hbase


    【解决方案1】:

    我找到原因了!因为有些列是多行的,而hive的默认行分隔符是\n,所以当你从hive外部表创建hive表时,数据行更大

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多