1 回答
- 最新
- 投票最多
- 评论最多
0
【以下的回答经过翻译处理】 版本本身在Athena中不可作为一个查询列使用。在Athena/Presto中,可以使用typeof函数来确定列的类型并选择如何处理。可以使用Case 函数。例如。
SELECT x, typeof(x)
from (select timestamp '2012-10-31 01:00 UTC' as x)
where typeof(x) like 'timestamp%'
UNION
SELECT date_parse(x,'%Y-%m-%d %h:%i:%s'), typeof(x)
from (select '2012-10-31 01:00:00' as x)
where typeof(x) like 'varchar%'
但理想情况下,即使在原始数据层中具有不同的Schema,也应该在ETL层中解析该Schema,以便在分析层中具有单个模式,可能有2个列 - 一个用于原始列,一个用于更改列。然后在服务层,如果需要将字符串列更改为时间戳,则轻松构建一个视图来合并列,例如:
SELECT coalesce(new_column, date_parse(old_column,'%m/%d/%Y %h:%i:%s %p')) as timestamp_column
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 3 年前
- AWS 官方已更新 1 年前