我目前正在尝试编写一个Athena查询,以获取表中过去7天的所有数据。
SELECT * FROM "engagement_metrics"."spikes" where spike_noticed_moment_utc > date_add('day', -7, now())
运行此查询时,我收到以下错误:
SYNTAX_ERROR: line 3:32: '>' cannot be applied to varchar, timestamp with time zone
在Athena中,我如何获取上周的数据?
看起来像柱子 spike_noticed_moment_utc 定义为varchar,您可以使用以下命令轻松地进行时间戳转换 from_iso8601_timestamp :
spike_noticed_moment_utc
SELECT * FROM "engagement_metrics"."spikes" where from_iso8601_timestamp(spike_noticed_moment_utc) > date_add('day', -7, now())