• 配置Hive 支持 JSON 存储



    1、说明

    hive默认使用分隔符如空格,分号,"|",制表符	来格式化数据记录,对于复杂数据类型如json,nginx日志等,就没有办法拆分了,这时候需要更加强大的SerDe来处理复杂数据,
    如使用JsonSerDe或者使用正则表达式RegSerDe来处理。


    2、下载jar包

    json-serde-1.3.8-jar-with-dependencies.jar:
    http://www.congiu.net/hive-json-serde/1.3.8/hdp23/json-serde-1.3.8-jar-with-dependencies.jar
    
    
    json-udf-1.3.8-jar-with-dependencies.jar:
    http://www.congiu.net/hive-json-serde/1.3.8/hdp23/json-udf-1.3.8-jar-with-dependencies.jar


    3、配置hive

    1、将下载的json-serde-1.3.8-jar-with-dependencies.jar包放到hive的lib目录下
    
    2、配置hive-site.xml文件,添加jar包的声明,永久注册
        <property>
            <name>hive.aux.jars.path</name>
            <value>file:///soft/hive/lib/json-serde-1.3.8-jar-with-dependencies.jar</value>
        </property>
    
    3、设置不压缩存储
        <property>
            <name>hive.exec.compress.output</name>
            <value>false</value>
        </property>


    4、建表语句语法

    hive> create table test(id int , name string) ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe' STORED AS TEXTFILE;
  • 相关阅读:
    Mac从零配置Vim
    Mac效率:配置Alfred web search
    看看你的邻居在干什么
    成功破解邻居的Wifi密码
    MacBook安装Win10
    C陷阱:求数组长度
    Nexus 6P 解锁+TWRP+CM
    搭建树莓派手机远程开门系统
    Ubuntu下配置ShadowS + Chrome
    JS传参出现乱码(转载)
  • 原文地址:https://www.cnblogs.com/weiyiming007/p/11969240.html
Copyright © 2020-2023  润新知