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

之后在進行建表等之類的工作

 



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM