雅典娜-DATE列中的JSON值正确 [英] Athena - DATE column correct values from JSON
问题描述
我有一个带有许多JSON文件的S3存储桶。
I have a S3 bucket with many JSON files.
JSON文件示例:
{"id":"x109pri", "import_date":"2017-11-06"}
import_date字段是DATE类型,标准格式为YYYY-MM-DD。
The "import_date" field is DATE type in standard format YYYY-MM-DD.
我正在雅典娜创建一个数据库连接来链接所有这些JSON文件。
I am creating a Database connection in Athena to link all these JSON files.
但是,当我在Athena中创建一个新表并将此字段格式指定为DATE时,我得到:内部错误,没有提供其他说明。要澄清的是,该表的创建很好,但是如果我要预览或查询该表,则会出现此错误。
However, when I create a new table in Athena and specify this field format as DATE I get: "Internal error" with no other explanation provided. To clarify, the table gets created just fine but if I want to preview it or query, I get this error.
但是,当我将此字段指定为STRING时,它将
However, when I specify this field as STRING then it works fine.
所以问题是,这是BUG还是Athena DATE格式的正确值?
So the question is, is this a BUG or what should be the correct value for Athena DATE format?
推荐答案
日期列类型不适用于SerDe和/或数据源的某些组合。
The date column type does not work with certain combinations of SerDe and/or data source.
例如,使用带有 org.openx.data.jsonserde.JsonSerDe
的DATE列失败,而 org.apache.hive.hcatalog.data.JsonSerDe $ c的DATE列失败$ c>有效。
For example using a DATE column with org.openx.data.jsonserde.JsonSerDe
fails, while org.apache.hive.hcatalog.data.JsonSerDe
works.
因此,使用以下表定义,查询JSON即可。
So with the following table definition, querying your JSON will work.
create external table datetest(
id string,
import_date date
)
ROW FORMAT serde 'org.apache.hive.hcatalog.data.JsonSerDe'
LOCATION 's3://bucket/datetest'
这篇关于雅典娜-DATE列中的JSON值正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!