AWS Athena客户端发生错误。 SYNTAX_ERROR:第2行第43个字符:'2023-02-07T23:59:59.613000 + 00:00'不是有效的时间戳文字。

0

【以下的问题经过翻译处理】 无法找到一种适当的方法来为我的Athena表parquet设置正确的时间戳属性数据类型,以便查询时间间隔。 我通过爬虫在从glue交互作业(PySpark)产生的parquet文件上创建表。

**下面是我的Athena表和我尝试的时间戳格式**

  1. ts(数据类型为timestamp):2023-02-07 23:59:59.460000
  2. ts_iso_stamp(数据类型为timestamp):2023-02-07 23:59:59.460000
  3. ts_iso_str(数据类型为timestamp):"2023-02-07T23: 59: 59.460000 + 00: 00"

我在我的glue作业中应用此映���来创建各种格式

ApplyMapping.apply(frame = dyf, mappings = [    ("date", "date", "date", "date")
                                                              ,("ts", "string", "ts", "timestamp")
                                                              ,("ts_iso", "string", "ts_iso_stamp", "timestamp")
                                                              ,("ts_iso", "string", "ts_iso_str", "string")  ]

当您在动态数据框上运行.show()时,ts_iso看起来像这样。 我所理解的ISO格式有效。

` "ts_iso":"2023-02-07T23:59:59.460000 + 00:00" `

![输入图像说明here](/媒体/postImages/original/IMwuWLVJkESiWoniIlgFhD8A)

查询示例失败相同的错误

select * from searchdb.queries_lu where appid = 'aHs7sPcX66ytv2FqmRnv'
                            AND ts >= TIMESTAMP '2023-02-07 23:59:59.405000'
                            AND ts <= TIMESTAMP '2023-02-08 00:00:00.637000';


select * from searchdb.queries_lu where appid =
profile picture
专家
已提问 5 个月前15 查看次数
1 回答
0

【以下的回答经过翻译处理】 最好避免存储字符串。

在您的示例中,您使用毫秒而不是微秒精度应该可以工作(也不要在日期和时间之间使用T),例如:

ts >= TIMESTAMP '2023-02-07 23:59:59.405'
profile picture
专家
已回答 5 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则