Skip to content

创建表语句:

create table  json_test(
  name string   comment "姓名",
  sailry int    comment "薪水",
  age int       comment "年龄",
  meta map<string,string> comment "附加信息"
)
partitioned by (batch_time int)
comment "JSON 格式表"
row format serde 'org.apache.hive.hcatalog.data.JsonSerDe'
stored as textfile;

Hive 添加 json 库支持

<property>
    <name>hive.aux.jars.path</name>
    <value>file:///Users/zhenqin/software/hive/lib/hive-hcatalog-core-1.2.2.jar,file:///Users/zhenqin/software/hive/lib/mysql-connector-java-5.1.34.jar</value>
</property>

加载 JSON 数据

load data inpath '/user/flume/testtopic/20190616/' 
into table json_test partition (batch_time=20190616);