MaxCompute中如何使用OSS外部表读取JSON数据?
2020-03-11 本文已影响0人
阿里云技术
一、打开OSS,上传json文件

json文件内容展示:
{"id":5644228109524316032,"sourceType":1}{"id":-736866360508848202,"sourceType":3}
二、登录DataWorks,建立外部表

建表语句:
CREATE EXTERNAL TABLE `json_table` ( `id` bigint, `sourcetype` int) ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe'STORED AS TEXTFILELOCATION 'oss://oss-cn-beijing-internal.aliyuncs.com/gjt-demo/home/jsondata/';
三、建立临时查询,查看数据

需要设置的flag语句以及查询语句
set odps.sql.type.system.odps2=true;set odps.sql.hive.compatible=true;select * from json_table;
查询结果展示:
