json建表_weixin_44491898的博客-CSDN博客_json表

1、先加载 rating.json 文件到 hive 的一个原始表 rate_json
create table rate_json(line string) row format delimited;
load data local inpath ‘/home/hadoop/rating.json’ into table rate_json;
2、创建 rate 这张表用来存储解析 json 出来的字段:
create table rate(movie int, rate int, unixtime int, userid int) row format delimited fields
terminated by ‘\t’;
解析 json,得到结果之后存入 rate 表:
insert into table rate select
get_json_object(line,’.movie′)asmoive,getjsonobject(line,′.movie′)asmoive,getjsonobject(line,′ .movie') as moive,get_json_object(line,'.movie′)asmoive,getj​sono​bject(line,′.rate’) as rate,
get_json_object(line,’.timeStamp′)asunixtime,getjsonobject(line,′.timeStamp′)asunixtime,getjsonobject(line,′ .timeStamp') as unixtime,get_json_object(line,'.timeStamp′)asunixtime,getj​sono​bject(line,′.uid’) as userid
from rate_json;
解决多字段如(||)
create table t_bi_reg(id string,name string)
row format serde ‘org.apache.hadoop.hive.serde2.RegexSerDe’
with serdeproperties(‘input.regex’=’(._)\|\|(._)’,‘output.format.string’=’%1ss s %2ss’)
stored as textfile;


Original url: Access
Created at: 2020-08-12 10:31:01
Category: default
Tags: none

请先后发表评论
  • 最新评论
  • 总共0条评论