【问题标题】:AWS Athena date_PartAWS Athena date_Part
【发布时间】:2018-01-28 10:46:50
【问题描述】:

我正在尝试使用 Athena 将日期截断为仅当天。 下面是输入和选择语句的样子:

create table ...
usagestartdate timestamp,
usageneddate timestamp,
 ...
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'serialization.format' = ',',
'field.delim' = ',',
"timestamp.formats" = "yyyy-MM-dd'T'HH:mm:ss.SSSSS'Z'") 
LOCATION 's3:

then to get just the day

select...
resource string
day(usagestartdate)
sum(usagehours)

【问题讨论】:

标签: amazon-web-services hive presto amazon-athena


【解决方案1】:

要检索时间戳列的日期,您需要使用底层 PrestoDB 引擎中的 datetime 函数。

所以结果选择如下所示:

select date(usagestartdate) date,
       date_diff('hour',usagestartdate,usageenddate) hours
from usagetable

【讨论】:

    猜你喜欢
    • 2020-04-12
    • 1970-01-01
    • 2020-06-27
    • 2017-10-19
    • 2018-11-06
    • 1970-01-01
    • 2020-09-12
    • 2021-12-22
    • 1970-01-01
    相关资源
    最近更新 更多