Search code examples
bigdatadata-warehousedatabase-partitioningvertica

HP Vertica: partition by TIMESTAMPTZ field


I'm trying to re-partition some table using week number counting from some day:

my_fact table contains a field called time_stamp of type TIMESTAMPTZ

Unfortunately, re-partition doesn't work, and I'm getting the error:

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

Should the cast of time_stamp to TIMESTAMP strip any time zone related info from this field thus making it deterministic?

Thanks!


Solution

  • Since I got no answer, I'm writing here what I've ended up with:

    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;
    

    This solution works.