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 個月前檢視次數 18 次
1 個回答
0

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

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

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

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南