hive处理json数据步骤:
1.加载hcatalog包,这个包已经在hive目录文件中:
hive> add jar ../hcatalog/share/hcatalog/hive-hcatalog-core-1.2.0.jar;
2.创建处理json格式数据的表( 注意’org.apache.hive.hcatalog.data.JsonSerDe’ ):
create table jsonTest(location string,ip string,action string,uid string,time string) row format serde 'org.apache.hive.hcatalog.data.JsonSerDe';
3.插入数据:
load data local inpath '/home/jsonTest.json' into table jsonTest;
注意:收集json数据,属性名不能是hive的关键字 ,hive不能把关键字作为列名!