Hive映射HBase表的几种方式
1.Hive内部表,语句如下
CREATE TABLE ods.s01_buyer_calllogs_info_ts(
key string comment "hbase rowkey",
buyer_mobile string comment "手机号",
contact_mobile string comment "对方手机号",
call_date string comment "发生时间",
call_type string comment "通话类型",
init_type string comment "0-被叫,1-主叫",
other_cell_phone string comment "对方手机号",
place string comment "呼叫发生地",
start_time string comment "发生时间",
subtotal string comment "通话费用",
use_time string comment "通话时间(秒)"
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,record:buyer_mobile,record:contact_mobile,record:call_date,record:call_type,record:init_type,record:other_cell_phone,record:place,record:start_time,record:subtotal,record:use_time")
TBLPROPERTIES("hbase.table.name" = "s01_buyer_calllogs_info_ts");
建好表之后,进入hbase shell执行list能看到表s01_buyer_calllogs_info_ts,hive drop掉此表时,hbase也被drop。
2.Hive外部表,语句如下,
create 'buyer_calllogs_info_ts', 'record', {SPLITS_FILE => 'hbase_calllogs_splits.txt'}
CREATE EXTERNAL TABLE ods.s10_buyer_calllogs_info_ts(
key string comment "hbase rowkey",
buyer_mobile string comment "手机号",
contact_mobile string comment "对方手机号",
call_date string comment "发生时间",
call_type string comment "通话类型",
init_type string comment "0-被叫,1-主叫",
other_cell_phone string comment "对方手机号",
place string comment "呼叫发生地",
start_time string comment "发生时间",
subtotal string comment "通话费用",
use_time string comment "通话时间(秒)"
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,record:buyer_mobile,record:contact_mobile,record:call_date,record:call_type,record:init_type,record:other_cell_phone,record:place,record:start_time,record:subtotal,record:use_time")
TBLPROPERTIES("hbase.table.name" = "buyer_calllogs_info_ts");
从方式需要先在hbase建好表,然后在hive中建表,hive drop掉表,hbase表不会变。
3.Hive映射HBase的列族
CREATE TABLE hbase_table_1(value map<string,int>, row_key int)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES (
"hbase.columns.mapping" = "cf:,:key"
);
INSERT OVERWRITE TABLE hbase_table_1 SELECT map(bar, foo), foo FROM pokes
WHERE foo=98 OR foo=100;
在hbase查看结果
hbase(main):012:0> scan "hbase_table_1"
ROW COLUMN+CELL
100 column=cf:val_100, timestamp=1267739509194, value=100
98 column=cf:val_98, timestamp=1267739509194, value=98
2 row(s) in 0.0080 seconds
在hive查看结果
hive> select * from hbase_table_1;
Total MapReduce jobs = 1
Launching Job 1 out of 1
...
OK
{"val_100":100} 100
{"val_98":98} 98
Time taken: 3.808 seconds
两种方式可以根据需求确定,详细参见官方文档。
Hive映射HBase表的几种方式的更多相关文章
- HBase读写的几种方式(二)spark篇
1. HBase读写的方式概况 主要分为: 纯Java API读写HBase的方式: Spark读写HBase的方式: Flink读写HBase的方式: HBase通过Phoenix读写的方式: 第一 ...
- Hive数据导入导出的n种方式
Tutorial-LoadingData Hive加载数据的6种方式 #格式 load data [local] inpath '/op/datas/xxx.txt' [overwrite] into ...
- 【转帖】HBase读写的几种方式(二)spark篇
HBase读写的几种方式(二)spark篇 https://www.cnblogs.com/swordfall/p/10517177.html 分类: HBase undefined 1. HBase ...
- HBase读写的几种方式(三)flink篇
1. HBase连接的方式概况 主要分为: 纯Java API读写HBase的方式: Spark读写HBase的方式: Flink读写HBase的方式: HBase通过Phoenix读写的方式: 第一 ...
- HBase读写的几种方式(一)java篇
1.HBase读写的方式概况 主要分为: 纯Java API读写HBase的方式: Spark读写HBase的方式: Flink读写HBase的方式: HBase通过Phoenix读写的方式: 第一种 ...
- T-SQL 循环表的一种方式
原文来自:https://www.lesg.cn/netdaima/sqlservert-sql/2016-463.html SsqlServer 中循环表有几种方式 1.临时表 2.游标 3-. 下 ...
- Hive与HBase表联合使用Join的问题
hive与hbase表结合级联查询的问题,主要hive两个表以上涉及到join操作,就会长时间卡住,查询日志也不报错,也不会出现mr的进度百分比显示,shell显示如下图 如图: 解决这个问题,需要修 ...
- iReport+jasperreport创建子表的几种方式(1)
在制作报表的过程中,子表是不可缺少的.今天就研究了一下制作子表的几种方式 一.连接数据库创建子表 以MySQL为例: 我的数据源数据库中的表 watermark/2/text/aHR0cDovL2Js ...
- 【解决】hive与hbase表结合级联查询的问题
[Author]: kwu [解决]hive与hbase表结合级联查询的问题.hive两个表以上,关联查询时出现长时无法返回的情况. 同一时候也不出现,mr的进度百分比. 查询日志如图所看到的: 解决 ...
随机推荐
- Python自学day-2
一.模块 模块分两种:标准库和第三方库,标准库是不需要安装就可以使用的库. import [模块名]:导入一个库,优先是在项目路径中寻找.自定义模块名不要和标准库模块名相同. sy ...
- 在同一页面中显示多个echart图表
整理了一下大概有两种做法来实现在同一个页面中显示多个echart图表,废话不说直接上代码. 在同一个echart对象中绘制多个图表 <!DOCTYPE html> <html lan ...
- 另一个ACM之路建议
ACM联系建议 一位高手对我的建议: 一般要做到50行以内的程序不用调试.100行以内的二分钟内调试成功.acm主要是考算法的 ,主要时间是花在思考算法上,不是花在写程序与debug上. 下面给个计划 ...
- GoLand Active Code
56ZS5PQ1RF-eyJsaWNlbnNlSWQiOiI1NlpTNVBRMVJGIiwibGljZW5zZWVOYW1lIjoi5q2j54mI5o6I5p2DIC4iLCJhc3NpZ25lZ ...
- 2019-2020年值得关注的9个AR发展趋势
作者Andrew Makarov,由计算机视觉life编辑:乔媛媛编译 更好的阅读体验请看首发原文链接 2019-2020年值得关注的9个AR发展趋势 增强现实技术在2019年实现了创纪录的发展.微软 ...
- mysql中id值被重置的情况
MySQL中,如果你为一张使用了innodb引擎的表指定了一auto_increment列,那么这张表会有一个auto_increment计数器,专门记录当前auto_increment的相关值,用来 ...
- 上传文件不落地转Base64字符串
1. 问题描述 因需调用第三方公司的图像识别接口,入参是:证件类型.图像类型.图片base64字符串,采用http+json格式调用. 本来采用的方式是:前端对图片做base64处理,后端组装下直接调 ...
- android_aidl
好久未更新博客了.人都是这样,刚开始对某一样东东冲劲十足,时间一长,很难坚持下去了,我这博客也是.所以我要打破成规,继续更新. 本次博客谈谈adil的用法.aidl的全称叫什么来着忘了,不过不要紧,重 ...
- vue组件之间的传值——中央事件总线与跨组件之间的通信($attrs、$listeners)
vue组件之间的通信有很多种方式,最常用到的就是父子组件之间的传值,但是当项目工程比较大的时候,就会出现兄弟组件之间的传值,跨级组件之间的传值.不可否认,这些都可以类似父子组件一级一级的转换传递,但是 ...
- 【译】深入理解G1的GC日志(一)
本文翻译自:https://www.redhat.com/en/blog/collecting-and-reading-g1-garbage-collector-logs-part-2?source= ...