Cannot use meta function or non-deterministic function in PARTITION BY expression

Hi all,

 

I want to create table, partitioned by days of month. I've tried alter table MY_TABLE_NAME partition by extract(DAY from starttime)::INT reorganize; but had ROLLBACK 2552:  Cannot use meta function or non-deterministic function in PARTITION BY expression. What is the problem? Thanks!
 

Comments

  • SruthiASruthiA Vertica Employee Administrator

    Hi,

     

       Can you check the data type of starttime? Is it timestamptz? if so, changing it to timestamp will work. Since timestamptz value changes according to the locale. All the expressions in Paritition by clause must be immutable. meaning that they return the exact same value regardless of when they are invoked, and independently of session or environment settings, such as LOCALE.

     

     

    -Regards,

     Sruthi

  • Thank you! You are right, it's timestamp with timezone. Do you meant something like this?

    CREATE TABLE public.test (
         date      TIMESTAMPTZ NOT NULL
    ) PARTITION BY EXTRACT(year FROM date AT TIME ZONE 'UTC');
     
    Maybe I can point only keyword LOCALE without specific value like 'UTC'?
  • SruthiASruthiA Vertica Employee Administrator

    Hi,

     

       Yeah, I meant the create table should be like the following

     

    CREATE TABLE public.test (
         date      TIMESTAMPTZ NOT NULL
    ) PARTITION BY EXTRACT(year FROM date AT TIME ZONE 'UTC');
     
     
    No, You cannot use the keyword LOCALE in the create table statement, since it is a environment setting and not specific to table. For more information on how to use TIME ZONE, please refer to 
     
     
    -Regards,
     Sruthi
     
     
  • Thanks very much!

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file