在本文中,我们介绍如何创建一个表在使用SerDe JSON数据集。
下载JSON SerDe JAR
- 打开hive-json-serde 1.3.8下载页面。
- 点击json-serde-1.3.8-jar-with-dependencies.jar下载的文件json-serde-1.3.8-jar-with-dependencies.jar。
在集群上安装JSON SerDe JAR
- 在工作区中选择您的集群。
- 单击库选项卡。
- 点击安装新。
- 在库源按钮列表中,选择上传。
- 在图书馆按钮类型列表中,选择JAR。
- 点击删除JAR这里。
- 选择json-serde-1.3.8-jar-with-dependencies.jar文件。
- 点击安装。
在create table语句中配置SerDe属性
% sql行格式SERDE org.openx.data.jsonserde。JsonSerDe org.apache.hadoop.mapred作为INPUTFORMAT存储。TextInputFormat OUTPUTFORMAT org.apache.hadoop.hive.ql.io。HiveIgnoreKeyTextOutputFormat“位置”< path-to-json-files >”
例如:
% sql create table < name-of-table > (timestamp_unix字符串,字符串,评论start_date字符串,end_date字符串)分区,(yyyy字符串,mm字符串,dd字符串)行格式SERDE org.openx.data.jsonserde。JsonSerDe org.apache.hadoop.mapred作为INPUTFORMAT存储。TextInputFormat OUTPUTFORMAT org.apache.hadoop.hive.ql.io。HiveIgnoreKeyTextOutputFormat“位置”< path-to-json-files >”这个例子创建了一个表分区的列yyyy,毫米,和弟弟。
运行后修复table语句创建表
例如:
% sql msck修理表< name-of-table >