簡體   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