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


    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.

    image

    当然,如果你使用的是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;

    其他的参照下表:

     image

    3.export hive DDL

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

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

    Looking for a job working at Home about MSBI
  • 相关阅读:
    QQ 表情大全
    Linux/Unix同Windows文件传输
    CentOS 5.2安装Oracle 10g
    用户名、密码测试用例
    界面测试用例
    PLSQL导入导出数据库
    JavaScript代码格式规范和注意事项
    Node.js 之发送文件数据编码问题
    Node.js 之IP地址和端口号
    Node.js 之ContentType内容类型
  • 原文地址:https://www.cnblogs.com/huaxiaoyao/p/4379788.html
Copyright © 2020-2023  润新知