Skip to main content

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

  • July 27, 2015
  • 4 replies
  • 19 views

Igor_Trosko
Forum|alt.badge.img+2

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!
 

4 replies

SruthiA
Forum|alt.badge.img+1
  • Participating Frequently
  • July 27, 2015

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


Igor_Trosko
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • July 27, 2015

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'?

SruthiA
Forum|alt.badge.img+1
  • Participating Frequently
  • July 27, 2015

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
 
 

Igor_Trosko
Forum|alt.badge.img+2
  • Author
  • Participating Frequently
  • July 27, 2015

Thanks very much!