如何从 Athena 中的 mongodb 对象 ID 检索时间戳

问题描述 投票:0回答:1

我已将数据从 mongodb 移至 AWS Athena。我需要在 Athena 中使用 SQL 从每条记录的 objectId 中提取时间戳。

我可以在 Postgre、Redshift 等中找到一些示例...但在 Athena 中找不到...

https://stackoverflow.com/questions/22454804/how-to-retrieve-the-date-from-a-mongodb-objectid-using-sql

示例输入:

507c7f79bcf86cd7994f6c0e

雅典娜的需求输出:

2012-10-15T21:26:17Z

mongodb amazon-athena presto trino objectid
1个回答
0
投票

使用 docs 中的相应函数翻译这个 MySQL 查询看起来很容易管理:

select from_base(substr('507c7f79bcf86cd7994f6c0e', 1, 8), 16);

输出:

            _col0
-----------------------------
 2012-10-15 21:26:17.000 UTC
© www.soinside.com 2019 - 2024. All rights reserved.