我试图使用某一天的周数计数重新划分一些表:
my_fact表包含一个名为time_stamp的TIMESTAMPTZ类型的字段。
不幸的是,重新分区不起作用,我得到了错误:
MyDB=> ALTER TABLE my_fact PARTITION BY MOD(TIMESTAMPDIFF('day', time_stamp::TIMESTAMP, TIMESTAMP '2013-09-23'), 156) REORGANIZE;
NOTICE 4954: The new partitioning scheme will produce 12 partitions
ROLLBACK 2552: Cannot use meta function or non-deterministic function in PARTITION BY expression是否应该将time_stamp转换为TIMESTAMP,删除来自该字段的任何时区相关信息,从而使其具有确定性?
谢谢!
发布于 2014-01-09 08:24:03
因为我没有答案,所以我在这里写下了我最后得到的:
ALTER TABLE my_fact PARTITION BY
MOD(
TIMESTAMPDIFF(
'day',
'2013-09-23'::timestamptz AT TIME ZONE 'UTC',
time_stamp AT TIME ZONE 'UTC'),
156)
REORGANIZE;这个解决方案起作用了。
发布于 2014-01-08 20:58:58
看看date_part()函数,您可以使用TIMESTAMPTZ作为它的源列:示例:
**The number of the week of the calendar year that the day is in.**
SELECT EXTRACT(WEEK FROM TIMESTAMP '2001-02-16 20:38:40');
Result: 7
SELECT EXTRACT(WEEK FROM DATE '2001-02-16');
Result: 7https://stackoverflow.com/questions/18977141
复制相似问题