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

多字节分隔符

时间:2019-06-17 00:58:37      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:还需   ati   nat   tor   path   local   支持   ted   分割   

一、简介

      在hive中默认只支持单字节分隔符,不支持多字节(超过一个字节)分割符的。

      单字节:|   .   :   \t

      多字节:||    ::     ..

      create table test01(id int,name string) row format delimited fields terminated by ‘::‘;

      load data local inpath ‘/home/hadoop/apps/test01‘ into table test01;

      上面导入数据之后,是不行的。

二、分割方式

1、将多字节换成单字节

      ::à:

      这样做有风险的

      1::Toy Story (1995)::Animation|Children‘s|Comedy

      1:Toy Story (1995):Animation|Children‘s|Comedy

      一定对数据足够了解,知道里面的数据的分隔都是利用相同的多字节来的。

2、修改源代码

      将hive源代码修改为支持多字节的,这样做的话,以后所有的数据都得是多字节切分的,遇到单字节切分的还需在改过来,所以不建议用这种方法。

3、自定义字段分割符(正则表达式)

create table test02(id int,name string)

row format serde ‘org.apache.hadoop.hive.serde2.RegexSerDe‘

with serdeproperties(‘input.regex‘=‘(.*)::(.*)‘,‘output.format.string‘=‘%1$s %2$s‘) stored as textfile;

load data local inpath ‘/home/hadoop/apps/test01‘ into table test02;

 

多字节分隔符

标签:还需   ati   nat   tor   path   local   支持   ted   分割   

原文地址:https://www.cnblogs.com/zhangxiaofan/p/11037430.html

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