Athena - DATE column correct values from JSON

旧巷老猫 提交于 2020-01-16 09:08:52

问题


I have a S3 bucket with many JSON files.

JSON file example:

{"id":"x109pri", "import_date":"2017-11-06"}

The "import_date" field is DATE type in standard format YYYY-MM-DD.

I am creating a Database connection in Athena to link all these JSON files.

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.

However, when I specify this field as STRING then it works fine.

So the question is, is this a BUG or what should be the correct value for Athena DATE format?


回答1:


The date column type does not work with certain combinations of SerDe and/or data source.

For example using a DATE column with org.openx.data.jsonserde.JsonSerDe fails, while org.apache.hive.hcatalog.data.JsonSerDe works.

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'


来源:https://stackoverflow.com/questions/47139525/athena-date-column-correct-values-from-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!