zoukankan      html  css  js  c++  java
  • Hive之SerDe&Beeline

    一.SerDe 

      SerDe:Serializer and Deserializer 序列化及反序列化,构建在数据存储和执行引擎之间,对两者实现解耦。

      Hive通过ROW FORMAT DELIMITED 以及SERDE进行内容的读写。

      样板:

      row format

      :DELIMITED 

        [FIELDS TERMIINATED BY char [ESCAPED BY char]

        [COLLECTION ITEMS TERMINATED BY char]

        [MAP KEYS TERMINATED BY char]

        [LINES TERMINATED BY char]

      :SERDE serde_name [WITH SERDEPROPERTIES (property_name=property_value,property_name=property_value...)]

      案例1:

        create table zhen(id int, name string,age int)

        row format delimited fields terminated by ','  collection items terninated by ',' map keys terminated by ':' lines terminated by ' ' ;

      案例2:

        create table zhen(id int, name string,age int)

        row format serde 'org.apache.hadoop.hive.serde2.RegexSerDe' with serdeproperties("input.regex" = "([^ ])([^ ])([^ ])") // 正则匹配

        stored as textfile;

      备注:lines 默认按照换行拆分!

    二.Beeline

      格式化数据表数据,Beeline要和HiveServer2配合使用。服务端启动hiveserver2,客户端通过beeline两种方式连接hive

      1.beeline -u jdbc:hive2://localhost:10000/default -n root

      2.1.beeline

      2.2 !connect jebc:hive2:/localhost:10000/defalut;auth-noSasl root 123

     

      

  • 相关阅读:
    约瑟夫问题
    再谈Bellman-Ford
    Uva 11478 Halum操作
    Uva 11090 在环中
    Bellman-Ford
    Uva 10537 过路费
    Uva 10917
    LA 3713 宇航员分组
    2-SAT
    LA 3211 飞机调度
  • 原文地址:https://www.cnblogs.com/yszd/p/10647859.html
Copyright © 2011-2022 走看看