1 下載對應版本的 jar包
http://mvnrepository.com/artifact/org.apache.hive.hcatalog/hive-hcatalog-core
add jar /home/xxx/hive-hcatalog-core-2.1.0.jar
2.創建表
CREATE TABLE json_table(id bigint, sourceType int)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'
STORED AS TEXTFILE;
3.加載數據
load data local inpath '/home/xxx/json.txt' into table json_table;
文件如下
{"id":5644228109524316032,"sourceType":1}
{"id":-736866360508848202,"sourceType":3}
4.
select * from json_table;
OK
5644228109524316032 1
-736866360508848202 3
注:本人是用的Hive的2.1.0版本