代码之家  ›  专栏  ›  技术社区  ›  Trenton Tyler

Athena Prestodb上周数据

  •  0
  • Trenton Tyler  · 技术社区  · 4 年前

    我目前正在尝试编写一个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中,我如何获取上周的数据?

    1 回复  |  直到 4 年前
        1
  •  0
  •   Philipp Johannis    4 年前

    看起来像柱子 spike_noticed_moment_utc 定义为varchar,您可以使用以下命令轻松地进行时间戳转换 from_iso8601_timestamp :

    SELECT *
    FROM "engagement_metrics"."spikes"
    where from_iso8601_timestamp(spike_noticed_moment_utc) > date_add('day', -7, now())
    
    推荐文章