PostgreSQL错误函数width_bucket(带时区的时间戳,不带时区的时间戳[])不存在

时间:2020-10-29 22:07:24

标签: postgresql

已经解决了问题-在这里发布是因为解决方案一直困扰着我,直到我翻译成中文blog post

ERROR:  function width_bucket(timestamp without time zone, timestamp with time zone[]) does not exist
LINE 3:     width_bucket(
            ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Error: Failed to prepare query: ERROR:  function width_bucket(timestamp with time zone, timestamp without time zone[]) does not exist
LINE 3: width_bucket(
        ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

1 个答案:

答案 0 :(得分:0)

解决方案是在系列发生器中指定时区(即下面的with time zone

select generate_series(
       timestamp with time zone '2020-10-02 13:43:00', 
       '2020-10-17 16:15:00', 
       '12 hours'))

..或实际上without time zone与您要与该系列分箱的数据匹配。使用select pg_typeof(timecolumn) from table limit 1;报告您的数据在概念上是否使用时区。