`
he91_com
  • 浏览: 375988 次
文章分类
社区版块
存档分类
最新评论

Hive建表实例——定义serdeproperties属性

 
阅读更多

创建table时,直接定义serdeproperties属性,

create table wzhg(
c0 string,
c1 string,
c2 string
)row format serde 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
with serdeproperties (
'input.regex' = 'bduid\\[(.*)\\]uid\\[(\\d+)\\]uname\\[(.*)\\]',
'output.format.string' = '%1$s\t%2$s'
) stored as textfile;

正则表达必须是java形式的。

添加字段时:

1、 更改serdeproperties的值

alter  table  table_name set  serdeproperties (‘charset’ = ‘GBK’,  ‘input.regex’=’ 'bduid\\[(.*)\\]uid\\[(\\d+)\\]’,  ‘output.format.string’ = ‘’………………………)

2、 删除\添加tablecolumns

alter table table_name add colums (id int);

如果创建表有问题的话,还需添加hive_contrib.jar

add $PATH/hive_contrib.jar

之后在进行建表等之类的工作


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics