0

我正在尝试使用从某一天开始计算的周数重新分区一些表:

my_facttable 包含一个名为time_stamptype的字段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_stampTIMESTAMP删除任何与时区相关的信息,从而使其具有确定性?

谢谢!

4

2 回答 2

1

看一下 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: 7
于 2014-01-08T20:58:58.673 回答
1

由于我没有得到答案,所以我在这里写下我最终得到的结果:

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-09T08:24:03.747 回答