首页 > 其他 > 详细

Hive Experiment 2(表动态分区和IDE)

时间:2015-03-31 07:50:52      阅读:211      评论:0      收藏:0      [点我收藏+]

1.使用oracle sql developer 4.0.3作为hive query的IDE。

下载hive-jdbc driver

http://www.cloudera.com/content/cloudera/en/downloads/connectors/hive/jdbc/hive-jdbc-v2-5-6.html

Start    Oracle    SQL    Developer    and    navigate    to    Preferences    |    Database    |    Third    Party
JDBC    Drivers.

Add    all    of    the    JAR    files    contained    in    the    unzipped    directory    to    the    Third-party
JDBC    Driver    Path   

then restart the oracle sql developer and then you can build the hive connection.

技术分享

当然,如果你使用的是apache的hive的话,你需要把hiveserver2启动起来接收请求。

可能出现的异常是你连接的user没有权限读取/tmp目录,因为hive请求会转化成mapreduce job运行,需要读写相关的

DFS的目录,目录权限检查可能会通不过,解决方案可自行搜索网络解决。

我使用的简单粗暴的方式:hadoop fs -chmod  -R 777 /tmp;

2.表动态分区测试

--create table employee(eid int, ename string) partitioned by (country string );
--create table dual as select num from nums where num<1;
--set hive.exec.dynamic.partition.mode=nonstrict
insert into table employee partition(country)
select *from (
select 1 ,‘yaoshuya‘,‘china‘ from dual
union all
select 2,‘yaoxiaohua‘,‘germany‘ from dual
) a

select * from employee;

需要用到的setting是:

set hive.exec.dynamic.partition;
set hive.exec.dynamic.partition.mode;
set hive.exec.max.dynamic.partitions.pernode;

需要开启动态分区,所以set hive.exec.dynamic.partition=true;

严格模式下需要至少一个静态的column,所以我们把它设置set hive.exec.dynamic.partition.mode=nonstrict;

其他的参照下表:

 技术分享

3.export hive DDL

思路,使用desc tablename可以返回表的列相关信息,可以使用此命令加上awk命令来分析前两列,拼装组成即可。

前两列表示列名和列的类型,第三列是comments可以忽略。

Hive Experiment 2(表动态分区和IDE)

原文:http://www.cnblogs.com/huaxiaoyao/p/4379788.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!