码迷,mamicode.com
首页 > 其他好文 > 详细

Hive之SerDe&Beeline

时间:2019-04-03 12:30:20      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:collect   jdb   format   int   name   property   数据存储   text   input   

一.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 ‘\n‘ ;

  案例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

 

  

Hive之SerDe&Beeline

标签:collect   jdb   format   int   name   property   数据存储   text   input   

原文地址:https://www.cnblogs.com/yszd/p/10647859.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!