aws athena - 通过 json 对象数组创建表 [英] aws athena - Create table by an array of json object
问题描述
我能否获得在 AWS Athena 上创建表的帮助.对于数据示例:
Can I get help in creating a table on AWS Athena. For a sample example of data :
[{"lts": 150}]
AWS Glue 将架构生成为:
AWS Glue generate the schema as :
array (array<struct<lts:int>>)
当我尝试使用 AWS Glue 创建的表来预览表时,出现此错误:
When I try to use the created table by AWS Glue to preview the table, I had this error:
HIVE_BAD_DATA: Error parsing field value for field 0: org.openx.data.jsonserde.json.JSONObject cannot be cast to org.openx.data.jsonserde.json.JSONArray
信息错误很清楚,但我找不到问题的根源!
The message error is clear, but I can't find the source of the problem!
推荐答案
在 AWS Athena 下运行的 Hive 正在使用 Hive-JSON-Serde 用于序列化/反序列化 JSON.出于某种原因,它们不仅仅支持任何标准的 JSON.他们要求每行一条记录,没有数组.用他们的话来说:
Hive running under AWS Athena is using Hive-JSON-Serde to serialize/deserialize JSON. For some reason, they don't support just any standard JSON. They ask for one record per line, without an array. In their words:
以下示例将起作用.
{ "key" : 10 }
{ "key" : 20 }
但这不会:
{
"key" : 20,
}
也不是这个:
[{"key" : 20}]
这篇关于aws athena - 通过 json 对象数组创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!