且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从嵌套JSON在Athena中创建表

更新时间:2023-11-03 10:21:16

查询JSON数据时,Athena要求使用每行一个JSON文档来格式化文件.从您的问题尚不清楚这是否是事实,您给出的示例是多行的,但这也许仅仅是为了使问题更清楚.

When querying JSON data Athena requires the files to be formatted with one JSON document per line. It's unclear from your question if this is the case or not, the examples you give are multiline, but perhaps that's only to make the question more clear.

您所包含的表DDL看起来应该可以在第二个示例数据上使用,但前提是它应格式化为每行一个文档,例如

The table DDL you include looks like it should work on the second example data, provided that it is formatted as one document per line, e.g.

{"emails": [{"label": "", "primary": "", "relationdef_id": "", "type": "", "value": ""}], "licenses": [{"allocated": "", "parent_type": "", "parentid": "", "product_type": "", "purchased_license_id": "", "service_type": ""}, { "allocated": "", "parent_type": "", "parentid": "", "product_type": "", "purchased_license_id": "", "service_type": ""}]}
{"emails": [{"label": "", "primary": "", "relationdef_id": "", "type": "", "value": ""}], "licenses": [{"allocated": "", "parent_type": "", "parentid": "", "product_type": "", "purchased_license_id": "", "service_type": ""}]}
{"emails": [{"label": "", "primary": "", "relationdef_id": "", "type": "", "value": ""}], "licenses": [{"allocated": "", "parent_type": "", "parentid": "", "product_type": "", "purchased_license_id": "", "service_type": ""}]}