【发布时间】:2017-09-23 22:06:32
【问题描述】:
我正在尝试查询这个 JSON 文件(出于调试目的,它只包含一行!):
{
"appVersion": null,
"sessionIndex": "3",
"psdkLang": null,
"lamdbaAwsRequestId": "bb04330c-e1e7-4bbd-97b8-86fdb2ee0b7f",
"bundleID": "xyz",
"receiveTimestamp": "2017-03-31T01:45:30.796Z",
"type": "logEvent",
"userIdfv": null,
"osVersion": null,
"uniqueIndex": "9c6c3927-aa66-4974-adac-fd10fc83a1e5",
"userIdfa": null,
"eventName": "Rewarded Ads Ad Is Ready",
"deviceType": null,
"eventId": "shardId-000000000005:49571690399037302251611429510623174446442870333536993362",
"store1": "google",
"deviceLang": null,
"geoCode": null,
"sessionId": "34B4CEC8-9AA0-40DD-94C4-C5420F563F68",
"params": "{\"AdProvider\":\"AdColony\",\"AdIsReady\":\"false\"}",
"gameVersion": null,
"internetConnectionState": null,
"deviceModel": null,
"deviceTimeZone": null,
"time": "2017-03-31T10:44:50.117+0900",
"userId": "24176983"
}
我在 Amazon Athena 中创建了一个表:
CREATE EXTERNAL TABLE IF NOT EXISTS RV_QA.RAAIR (
`appversion` string,
`psdklang` string,
`bundleid` string,
`receivetimestamp` string,
`type` string,
`osversion` string,
`store1` string,
`devicelang` string,
`geocode` string,
`sessionid` string,
`eventName` string,
`params` map<string,string>
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = '1'
) LOCATION 's3://...'
TBLPROPERTIES ('has_encrypted_data'='false');
当我运行这个查询时:select eventname from RAAIR;
一切正常。
当我尝试使用嵌套 JSON(params 元素)时:select params['AdIsReady'] from RAAIR;
我收到“内部错误”消息。
我在这里错过了什么?
【问题讨论】:
-
可能是错误日志? :-)
-
错误日志中没有任何内容。经过长时间的研究,我发现问题出在 params 元素中:它的值被转义 - \" 而不是 " 并且 Athena 不知道如何处理它。有什么办法可以告诉雅典娜忽略这个转义字符?
-
正如我之前的评论中提到的,我发现了问题所在。现在的问题是解决方案是什么。
标签: json amazon-athena