在 Athen Table 中指定时间戳或日期格式

Specifying timestamp or date format in Athen Table

我有一个 ISO-8601 格式的时间戳,我想在 Athena 中创建 table 时将其指定为 timestampdatetime 格式。关于如何执行此操作的任何线索?

谢谢!

当您在 Athena 中 create table 时,您只能将列设置为 Unix 格式的日期或时间戳,如下所示:

  • DATE, in the UNIX format, such as YYYY-MM-DD.

  • TIMESTAMP. Instant in time and date in the UNiX format, such as yyyy-mm-dd hh:mm:ss[.f...]. For example, TIMESTAMP '2008-09-15 03:04:05.324'. This format uses the session time zone.

如果格式不同,将其定义为字符串,当您查询数据时使用 date function:

from_iso8601_date(string) → date

您可以使用 CTAS(将 table 创建为 select)查询转换数据,以使其更容易、更便宜地用于特定用例,该查询将生成数据的新副本更简单、更高效(压缩和柱状)镶木地板格式的数据。