[英]invalid format MST using amazon athena at_timezone function sql/presto
So I have the original where clause like so:所以我有这样的原始 where 子句:
--date_parse(coalesce(nullif(cc.timemodified , ''),nullif(cc.timecreated , ''), '2500-01-01 15:01:01 '),'%Y-%m-%d %H:%i:%s') >= date_add('hour', -36, date_parse('2022-11-07 14:08:22','%Y-%m-%d %H:%i:%s'))
I want to convert it to be more incremental using the Athena at_timezone function, I have the below so far:我想使用 Athena at_timezone function 将其转换为更多增量,到目前为止我有以下内容:
at_timezone(parse_datetime(coalesce(nullif(cc.timemodified || 'MST', ''),nullif(cc.timecreated || 'MST', ''), '2022-11-01 22:25:32 MST'),'YYYY-MM-dd HH:mm:ss z'), 'US/Mountain') >= parse_datetime('2022-11-01 22:25:32 EST', 'YYYY-MM-dd HH:mm:ss z')
--date_parse(coalesce(nullif(cc.timemodified , ''),nullif(cc.timecreated , ''), '2500-01-01 15:01:01 '),'%Y-%m-%d %H:%i:%s') >= date_add('hour', -36, date_parse('2022-11-07 14:08:22','%Y-%m-%d %H:%i:%s'))
But this isnt working and producing the error:但这不起作用并产生错误:
INVALID_FUNCTION_ARGUMENT: Invalid format: "MST"
This query ran against the "some data" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id:
where am I messing up?我在哪里搞砸了?
Your format ('YYYY-MM-dd HH:mm:ss z') works fine for me:您的格式 ('YYYY-MM-dd HH:mm:ss z') 适合我:
select parse_datetime('2022-11-01 22:25:32 MST','YYYY-MM-dd HH:mm:ss z');
Output: Output:
_col0 ![]() |
---|
2022-11-01 22:25:32.000 America/Denver ![]() |
It seems that you are missing space in your concat, try adding it - cc.timemodified || 'MST'
看起来你的 concat 中缺少空间,尝试添加它 -
cc.timemodified || 'MST'
cc.timemodified || 'MST'
-> cc.timemodified || ' MST'
cc.timemodified || 'MST'
-> cc.timemodified || ' MST'
cc.timemodified || ' MST'
UPD更新程序
Also you need to fix the nullif
handling - move concatenation with MST
outside of the coalesce
call (and remove it from nullif
's) - coalesce(nullif(field, ''), nullif(...),..) || 'MST'
您还需要修复
nullif
处理 - 在coalesce
调用之外移动与MST
的连接(并将其从nullif
中删除) - coalesce(nullif(field, ''), nullif(...),..) || 'MST'
coalesce(nullif(field, ''), nullif(...),..) || 'MST'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.