前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >hbase mapping hive error

hbase mapping hive error

原创
作者头像
大数据工程师-公子
发布2019-03-12 11:26:58
7970
发布2019-03-12 11:26:58
举报

hbase mapping hive error

error msg

message:org.apache.hadoop.hive.serde2.SerDeException org.apache.hadoop.hive.hbase.HBaseSerDe: columns has 6 elements while hbase.columns.mapping has 7 elements (counting the key if implicit))

原因

在创建hive/hbase相关联的表时,hbase表结构默认会有一个字段key,如果没有一个显示的字段'key'那么在创建表的进修,会自己创建,这样hive对应的表就会出现问题,所以在hive对应的表里一定要加上key这个字段,为了避免这个问题,在hbase表结构里可以显示的添加'key'字段,这样不容易出问题。

正确mapping格式

代码语言:txt
复制
use ods;
drop table ods.hbase_mapping_crm_client_details;
CREATE EXTERNAL TABLE ods.hbase_mapping_crm_client_details(
`row_key` string comment "hbase rowkey",
`cust_id` string comment "代理主键,由全局ID服务生成",
`vcc_id` int comment "企业ID",
`original_id` int comment "原始的客户ID(用于记录老crm中的客户数据的ID)",
`cust_name` string comment "客户名称",
`cust_pinyin` string comment "客户名称对应的拼音全拼",
`phone_num` string comment "客户电话"
)STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = "i:cust_id#b,i:vcc_id#b,i:original_id#b,i:cust_name,i:cust_pinyin,i:phone_num")
TBLPROPERTIES("hbase.table.name" = "ns_ods:data_client_details");

或者

代码语言:txt
复制
use ods;
drop table ods.hbase_mapping_crm_client_details;
CREATE EXTERNAL TABLE ods.hbase_mapping_crm_client_details(
`row_key` string comment "hbase rowkey",
`cust_id` string comment "代理主键,由全局ID服务生成",
`vcc_id` int comment "企业ID",
`original_id` int comment "原始的客户ID(用于记录老crm中的客户数据的ID)",
`cust_name` string comment "客户名称",
`cust_pinyin` string comment "客户名称对应的拼音全拼",
`phone_num` string comment "客户电话"
)STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,i:cust_id#b,i:vcc_id#b,i:original_id#b,i:cust_name,i:cust_pinyin,i:phone_num")
TBLPROPERTIES("hbase.table.name" = "ns_ods:data_client_details");

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • hbase mapping hive error
    • error msg
      • 原因
        • 正确mapping格式
        相关产品与服务
        TDSQL MySQL 版
        TDSQL MySQL 版(TDSQL for MySQL)是腾讯打造的一款分布式数据库产品,具备强一致高可用、全球部署架构、分布式水平扩展、高性能、企业级安全等特性,同时提供智能 DBA、自动化运营、监控告警等配套设施,为客户提供完整的分布式数据库解决方案。
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档