aws雅典娜日期部分

3qpi33ja  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(493)

我想用雅典娜把日期缩短到今天。输入和选择语句如下所示:

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)
a2mppw5e

a2mppw5e1#

要检索timestamp列的日期,需要使用基础prestodb引擎中的datetime函数。
因此,生成的select如下所示:

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

相关问题