创建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

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

 


相关文章:

  • 2022-01-05
  • 2022-12-23
  • 2021-09-02
  • 2021-12-06
  • 2022-02-16
猜你喜欢
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案