博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hive:分区表,hbase外表
阅读量:2111 次
发布时间:2019-04-29

本文共 2049 字,大约阅读时间需要 6 分钟。

1, hive创建hbase外表

  • a, hive表有数据  —> 给hbase表用:  映射时,自动创建hbae表
  • b, hbase表有数据 —> 给hive表用
CREATE EXTERNAL TABLE  [dbname.]表名( rowkey string, name string) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping"= ":key, f:name") TBLPROPERTIES ("hbase.table.name" = "hbase表");

2, 创建分区表:插入数据( 动态分区,手动分区)

create table users(id int,user_id int,user_name string);create table product(id int,product_id int,product_name string,price double);create table orders (id int,user_id int,product_id int,product_count int) partitioned by (year string,month string,day string);--------------指定分区:插入数据insert into users values(1,1,'a'),(2,2,'b'),(3,3,'c');insert into product values(1,1,'iphone6',9000),(2,2,'<
>',23.2),(3,3,'lenovo-pc',5623.4);insert into orders partition(year='2019',month='03',day='02') values(1,1,1,2),(2,1,3,1),(3,2,2,3);insert into orders partition(year='2019',month='03',day='03') values(null,1,2,1),(null,2,1,4);------------动态分区:插入数据:create table orders_t1 (id int,user_id int,product_id int,product_count int,time string) ;insert into orders_t1 values(1,1,1,2,'2011-12-02 12:03:32'),(2,1,3,1,'2014-12-05 16:06:32'),(3,2,2,3,'2016-10-02 18:03:32');set hive.exec.dynamic.partition.mode=nonstrict;create table orders2 like orders;insert into orders2 partition(year,month,day)select id,user_id,product_id,product_count,year(time),month(time),day(time) from orders_t1;--====================查询语句--解决错误:Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask (state=08S01,code=1)SET hive.exec.mode.local.auto=true;SET hive.auto.convert.join=false;SET mapreduce.map.memory.mb = 26384; SET mapreduce.map.java.opts='-Djava.net.preferIPv4Stack=true -Xmx23107M';SET mapreduce.reduce.memory.mb = 26384; SET mapreduce.reduce.java.opts='-Djava.net.preferIPv4Stack=true -Xmx23107M';set hive.support.concurrency = false;select user_name, product_name, product_count from ordersleft join product on product.product_id=orders.product_idleft join users on users.user_id=orders.user_id

转载地址:http://zhdef.baihongyu.com/

你可能感兴趣的文章
第一次kaggle比赛 回顾篇
查看>>
leetcode 50. Pow(x, n)
查看>>
leetcode 130. Surrounded Regions
查看>>
【托业】【全真题库】TEST2-语法题
查看>>
博客文格式优化
查看>>
【托业】【新托业全真模拟】疑难语法题知识点总结(01~05)
查看>>
【SQL】group by 和order by 的区别。
查看>>
【Python】详解Python多线程Selenium跨浏览器测试
查看>>
Jmeter之参数化
查看>>
Shell 和Python的区别。
查看>>
Python 列表(list)、字典(dict)、字符串(string)常用基本操作小结
查看>>
Loadrunner之https协议录制回放报错如何解决?(九)
查看>>
python中xrange和range的异同
查看>>
列表、元组、集合、字典
查看>>
【Python】easygui小甲鱼
查看>>
【Python】关于Python多线程的一篇文章转载
查看>>
【Pyton】【小甲鱼】文件
查看>>
【Pyton】【小甲鱼】永久存储:腌制一缸美味的泡菜
查看>>
【Pyton】【小甲鱼】异常处理:你不可能总是对的
查看>>
APP性能测试工具
查看>>