繁体   English   中英

AWS Athena 嵌套 JSON 错误

[英]AWS Athena Nested JSON error

我有一个嵌套的 JSON 文件,如下所示:

\n  \"total\" : 510,\n  \"start\" : 0,\n  \"count\" : 500,\n  \"data\" : [ {\n    \"id\" : 294,\n    \"candidate\" : {\n      \"id\" : 5275,\n      \"firstName\" : \"bob\",\n      \"lastName\" : \"bob\"\n    },\n    \"sendingUser\" : {\n      \"id\" : 5,\n      \"firstName\" : \"tom\",\n      \"lastName\" : \"tom\"\n    },\n    \"dateAdded\" : 1487865908960,\n    \"jobOrder\" : {\n      \"id\" : 71,\n      \"title\" : \"Job\"\n    },\n    \"status\" : \"1st Interview\",\n    \"_score\" : 1.0\n  }

我将此存储在 S3 中,并尝试在 AWS Athena 中创建一个表,我所做的编辑器如下:

CREATE EXTERNAL TABLE IF NOT EXISTS cvtest (
  data struct < candidate struct <id string, firstName string, lastName string>,
                sendingUser struct <id string, firstName string, lastName string>,
                dateAdded string,
                jobOrder string,
                score string
              > 
  )           
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
LOCATION 's3://es-cvsent'; 

但是查询在下面遇到错误;

FAILED: ParseException line 2:26 missing : at 'struct' near '<EOF>' line 2:37 missing : at 'string' near '<EOF>' line 2:55 missing : at 'string' near '<EOF>' line 2:72 missing : at 'string' near '<EOF>' line 3:28 missing : at 'struct' near '<EOF>' line 3:39 missing : at 'string' near '<EOF>' line 3:57 missing : at 'string' near '<EOF>' line 3:74 missing : at 'string' near '<EOF>' line 4:26 missing : at 'string' near '<EOF>' line 5:25 missing : at 'string' near '<EOF>' line 6:22 missing : at 'string' near '<EOF>'

This query ran against the "test" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: 84e876e8-b947-490e-b2b6-7bf9c376266e.

谁能看到我做错了什么?

数据本身看起来不像有效的 JSON,但无论如何您都应该能够创建一个表,因为此时底层数据未经过验证。 (之后只是查询表是行不通的)。

您遇到的问题是您的语法错误,请参阅此文档。在结构定义中的列和数据类型之间使用了“:”。

这应该工作

data struct<candidate:struct<id:string, firstName:string, lastName:string>,
                sendingUser:struct<id:string, firstName:string, lastName:string>,
                dateAdded:string,
                jobOrder:string,
                score:string
              >   

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM