一、打开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 TEXTFILE
LOCATION '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;
查询结果展示:
欢迎加入“MaxCompute开发者社区2群”,点击链接申请加入或扫描二维码
https://h5.dingtalk.com/invite-page/index.html?bizSource=____source____&corpId=dingb682fb31ec15e09f35c2f4657eb6378f&inviterUid=E3F28CD2308408A8&encodeDeptId=0054DC2B53AFE745